#coding: utf-8
"""
this programe is to clear driverlog below this dir
__author__:the_new_one
"""
import os, traceback #查找文件名中包含关键词的文件
def search_dir(s, path=os.path.abspath('.'),files = []):
try:
for x in os.listdir(path):
path_now = os.path.join(path, x)
if os.path.isfile(path_now) and s in os.path.splitext(x)[0]:
print path_now
#删除查找到的文件
os.remove(path_now)
if x not in files:
files.append(x)
elif os.path.isdir(x):
search_dir(s=s, path=os.path.join(path_now), files=files)
return files
except Exception, e:
print traceback.format_exc()
print e if __name__ == "__main__":
result = search_dir(s='xxx')

通过遍历当前路径下的文件,判断文件名是否包含s,如果是就删除。

最新文章

  1. app的meta标签
  2. request 路径随笔
  3. Mysql分支
  4. 实例源码--Android手机狗(防盗)源码
  5. 九度OJ 1118 数制转换
  6. mac 布置 git仓库服务器
  7. 读书笔记之 - javascript 设计模式 - 责任链模式
  8. delphi列表视图组件(TListView)使用方法|实例
  9. Codecademy学习打卡1
  10. Swift - 多线程实现方式(3) - Grand Central Dispatch(GCD)
  11. Java中WebService实例
  12. Jquery源码分析与简单模拟实现
  13. Linux网络技术管理及进程管理
  14. RestSharp发送请求得到Json数据
  15. 第五篇:数据备份、pymysql模块
  16. react框架实现点击事件计数小案例
  17. python标准库 - 数学库和随机数库
  18. 【python基础】利用pandas处理Excel数据
  19. Dell服务器Raid5之后安装系统
  20. linux下面得小数计算

热门文章

  1. Python学习-day15-JavaScript
  2. [oldboy-django][2深入django]xss攻击 + csrf
  3. Zookeeper CreateMode
  4. linux配置Hadoop伪分布安装模式
  5. File IO(NIO.2):什么是路径?
  6. 【bzoj4810】[Ynoi2017]由乃的玉米田 莫队算法+STL-bitset
  7. Codeforces Round #330 (Div. 2) B 容斥原理
  8. react-router 4.0版本学习笔记
  9. 带接口的webservice 的发布
  10. boost 库的下载和编译_Visual Studio 2013(转)