How can I delete files from recycle bin in windows? python

懵懂的女人 提交于 2020-05-13 17:58:29

问题


I'm trying to delete files that are in the recycle bin by using python, but i can't find a way to do it. Thanks.


回答1:


For the Windows OS you can use the winshell module and it's empty method.

Emptying the recycle bin is as easy as:

import winshell
winshell.recycle_bin().empty(confirm=False, show_progress=False, sound=False)

See some examples here.




回答2:


There's a Windows shell module wrapped by PyWin32 that does this, assuming the question is for Windows.

http://timgolden.me.uk/pywin32-docs/shell__SHEmptyRecycleBin_meth.html



来源:https://stackoverflow.com/questions/42089399/how-can-i-delete-files-from-recycle-bin-in-windows-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!