#!/usr/bin/env python
#-*- coding: utf-8 -*-
import win32con, win32api,shutil,os
def removePath(destinationPath):
'''
@summary: 删掉destinationPath目录,当然包括其中的子目录和文件
@param destinationPath: 所给目标目录
'''
if os.path.exists(destinationPath):
pathList = os.listdir(destinationPath)
for path in pathList:
pathFull = os.path.join(destinationPath,path)
if os.path.isfile(pathFull):
win32api.SetFileAttributes(pathFull, win32con.FILE_ATTRIBUTE_NORMAL)
if os.path.isdir(pathFull):
removePath(pathFull)
shutil.rmtree(destinationPath,True)
if __name__ == '__main__':
path = r'e:testtest'
removePath(path)
最后
以上就是执着美女最近收集整理的关于python删除非空目录的方法的全部内容,更多相关python删除非空目录内容请搜索靠谱客的其他文章。
发表评论 取消回复