admin管理员组文章数量:1660119
我正在研究复位按钮。该按钮用于清除文本小部件中生成的文本,并删除正在写入数据的文件。清除文本小部件可以工作,但是删除文件时遇到问题。在
当我试图从windows中删除它时,它说它仍然在Python中打开。所以,我先从代码中关闭了它,然后试图删除它,但没有成功。在
我已经编程了另一个按钮,这样它就不会覆盖文件。所以,我不能只删除文件中已经写入的数据。在
有没有办法可以强制删除那个文件??在
我使用的是python2.6.6。在
这是我在重置按钮上的代码:def reset_it(self):
self.run.update() # run is the other button, I have to stop it's processing!
self.Outputlines.update() # Forcing the TextWidget to update.
self.Outputlines.config(state=NORMAL)
self.Outputlines.delete(1.0, END) # Clearing everything from the TextWidget.
self.Outputlines.config(state=DISABLED)
self.run.wait_variable() # Stopping the run button.
self.infile.close() # Closing the file.
os.remove(self.filename.get()) # Code to delete the file.
版权声明:本文标题:python强制关闭文件_正在强制删除文件。Python,Windows 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1729845084a1215036.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论