【发布时间】:2015-05-12 06:00:25
【问题描述】:
我写了一个函数,当我的程序完成它的工作时调用它。
def allDone(self, event):
dlg = wx.MessageBox("All done!", "Ask Alfred", wx.OK | wx.ICON_INFORMATION)
os.unlink(self.fpath)
os.rename(self.temp, self.fpath)
self.pathBox.Clear()
但是,它没有按预期工作。它应该删除原始文件,然后将临时文件重命名为原始文件路径。
相反,它只执行取消链接,删除 self.fpath 中的文件。
我得到的确切错误是:
File "G:/AskNorbert/finder.py", line 151, in allDone
os.rename(self.temp, self.fpath)
WindowsError: [Error 32] The process cannot access the file because it is being used by another process
【问题讨论】:
-
检查你的程序中是否没有关闭临时文件
标签: python operating-system wxpython