python删除带特殊后缀的文件
2015-11-18 10:12
651 查看
import os
import time
path = "F:\\zjbg" #文件夹路径
suffix = ".html" #需要删除的文件类型
def GetFileList(dir, fileList):
newDir = dir
if os.path.isfile(dir):
if dir.endswith(suffix) :
fileList.append(dir)
os.remove(dir)
print "删除文件名:" + dir
elif os.path.isdir(dir):
for s in os.listdir(dir):
newDir=os.path.join(dir,s)
GetFileList(newDir, fileList)
return fileList
list = GetFileList(path, [])
print "已删除当前所有"+suffix+"文件:"
import time
path = "F:\\zjbg" #文件夹路径
suffix = ".html" #需要删除的文件类型
def GetFileList(dir, fileList):
newDir = dir
if os.path.isfile(dir):
if dir.endswith(suffix) :
fileList.append(dir)
os.remove(dir)
print "删除文件名:" + dir
elif os.path.isdir(dir):
for s in os.listdir(dir):
newDir=os.path.join(dir,s)
GetFileList(newDir, fileList)
return fileList
list = GetFileList(path, [])
print "已删除当前所有"+suffix+"文件:"
相关文章推荐
- 小心服务器内存居高不下的元凶--WebAPI服务
- 运维入门
- Linux5.9无人值守安装
- 数据中心和云未来的十二大趋势
- 用vsftp快速搭建ftp服务器
- Linux快速构建apache web服务器
- 服务器监控策略浅谈
- 如何降低服务器采购成本 原理分析
- 建议的服务器分区办法
- 服务器托管六大优势分析
- Erlang实现的一个Web服务器代码实例
- 服务器技术全面解析
- 保护DNS服务器的几点方法小结
- 我国成为全球第二大服务器消费国
- 服务器 安全检查要点[星外提供]
- 服务器应用自动重新启动IIS批处理[原创]_DOS/BAT_脚本之家
- FTP 服务器关于权限的问题
- 批处理设置windows服务器的代码ThecSafe1.9.4第1/3页
- Apache服务器配置全攻略