Python删除文件到回收站

来源:互联网 发布:js包含字符串 indexof 编辑:程序博客网 时间:2024/05/22 01:29
利用active python里面的shell模块可以完成删除到回收站的操作,如下:
from win32com.shell import shell,shellcon

def deltorecyclebin(filename):
    shell.SHFileOperation((0,shellcon.FO_DELETE,filename,None,/
        shellcon.FOF_SILENT | /
        shellcon.FOF_ALLOWUNDO | /
        shellcon.FOF_NOCONFIRMATION,
        None,None))

filename主要用完整路径,SHFileOperation的具体用法可以参见msdn。
原创粉丝点击