我已经使用tempfile.mkstemp()
创建了临时文件,创建之后,我得到了path
中文件的唯一路径,现在我想删除这个临时文件。我的代码如下所示。在
我已经访问过这个WindowsError: [Error 32] The process cannot access the file because it is being used by another process: 'new.dat' ,但没有解决我的问题。在
编码
import os
import tempfile
path=tempfile.mkstemp('.png', 'bingo',
'C:\\Users\\MuhammadUsman\\Documents\\PythonScripts\\Project')
os.unlink(path)
错误
^{pr2}$
如果你只想得到唯一的名字,那么试试这个。这比上面的解决方案好。不需要删除该文件。文件将自动删除。在
试试这个:这个对我有用。在
相关问题 更多 >
编程相关推荐