python删除特定文件的方法
2015-07-30 00:00
731 查看
本文实例讲述了python删除特定文件的方法。分享给大家供大家参考。具体如下:
#!/usr/bin/python # -*- coding: utf-8 -*- import os def del_files(path): for root , dirs, files in os.walk(path): for name in files: if name.endswith(".CR2"): os.remove(os.path.join(root, name)) print ("Delete File: " + os.path.join(root, name)) # test if __name__ == "__main__": path = '/Users/yjatt/Downloads/1104/' del_files(path)
希望本文所述对大家的Python程序设计有所帮助。
相关文章推荐
- Python实现批量读取word中表格信息的方法
- 使用Python脚本生成随机IP的简单方法
- Python实现简单拆分PDF文件的方法
- Python利用正则表达式匹配并截取指定子串及去重的方法
- Python统计文件中去重后uuid个数的方法
- Python实现配置文件备份的方法
- Python实现根据IP地址和子网掩码算出网段的方法
- Python实现的Excel文件读写类
- python学习之第三方包安装方法(两种方法)
- python查看FTP是否能连接成功的方法
- Python读取网页内容的方法
- python简单分割文件的方法
- Python 通用任务分发器
- python内置函数(四)
- Python爬虫基础(一)--简单的url请求
- python 项目 Memory game
- Python文件操作读写文件
- Python的字典排序
- 《learning python the hard way》习题46 项目骨架搭建 问题小结(二)之 自动化测试代码问题
- python解析网页时的错误(EOF in middle of construct)