【发布时间】:2021-10-09 16:25:38
【问题描述】:
为什么这不起作用? 它打印 a,iv 检查路径及其指向正确的位置。
def delete_file():
try:
file2remove = pathtofiles+clicked
if os.path.exists(file2remove):
os.remove(file2remove)
idx = listbox.get(0, tk.END).index(clicked)
listbox.delete(idx)
else:
print("The file does not exist")
except Exception as e:
from main import log_error
log_error(e, "notepad_delete_file")
同时更改权限
os.chmod(file2remove, "0777")
它就像它已经删除它一样工作,但它没有,关闭应用程序,刷新它并没有。
这也是昨天的工作,从那以后我没有对代码进行任何更改......
有什么想法吗?
【问题讨论】:
-
这一行中有两个括号是否有原因:
os.remove(file2remove))? -
wxz 我的错,但这不是它不工作的原因
-
这能回答你的问题吗? Python: os.remove is not working
-
不,因为它没有给出任何错误,我更新了我的完整代码,我有异常并且什么都没有。
-
试试this
标签: python-3.x operating-system