错误信息:
Traceback (most recent call last):
File "D:\workspace\python\Python_First\12File.py", line 64, in <module>
os.rename('file.txt', 'newName.txt')
WindowsError: [Error 32]
原因及解决方案:
是文件操作错误,原因是在对file.txt进行重命名之前file.txt文件没有关闭.
在对file.txt进行操作时需要添加上:
f2.flush()
f2.close()