I have the following code:
os.remove('_Temp_Dir_\main' + str(i) + '.exe')
os.rmdir('_Temp_Dir_')
这使我得到:
OSError: [WinError 145] Directory is not empty: '_Temp_Dir_'
如果我放置这行代码
time.sleep(0.05)
os.rmdir()
之前,一切都正常。我认为os.remove()
删除文件的速度不够快。有没有办法等待它完成工作?