网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Python通过win32api递归遍历目录删除指定文件的代码

如下的内容是关于Python通过win32api递归遍历目录删除指定文件的内容。

成都创新互联公司自2013年起,是专业互联网技术服务公司,拥有项目成都网站建设、成都做网站网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元静宁做网站,已为上家服务,为静宁各地企业和个人服务,联系电话:18980820575

import win32con
import win32api
import os

def del_dir(self,path):
    for file in os.listdir(path):
        file_or_dir = os.path.join(path,file)
        if os.path.isdir(file_or_dir) and not os.path.islink(file_or_dir):
            del_dir(file_or_dir) #it's a directory reucursive call to function again
        else:
            try:
                os.remove(file_or_dir) #it's a file, delete it
            except:
                #probably failed because it is not a normal file
                win32api.SetFileAttributes(file_or_dir, win32con.FILE_ATTRIBUTE_NORMAL)
                os.remove(file_or_dir) #it's a file, delete it
        os.rmdir(path) #delete the directory here

网站题目:Python通过win32api递归遍历目录删除指定文件的代码
当前URL:http://bjjierui.cn/article/pdjegi.html

其他资讯