python 遍历指定文件夹下的所有文件内容
2015-09-17 17:55
411 查看
最近公司代码需要做版权审查需要一些代码,足足60页的word文档,
如果一个一个文件的copy代码 就真是out,最近在学习python,就写了个python的脚本,方便上面操作。
如果一个一个文件的copy代码 就真是out,最近在学习python,就写了个python的脚本,方便上面操作。
__author__ = 'jghost' import os for root,dirs,files in os.walk('your source'): print root #path for name in files: if name.endswith('.java'): dic = open('/home/jghost/filefilter.txt','a') dic.write('\n') dic.write('\n') dic.write(name+'\n') dic.write('#author:jgost\n') dic.write('#company:xxxx\n') source = open(root+'/'+name) while True: context = source.readline() if context.strip().startswith('#'): continue dic.write(context) if not context: break source.close() dic.close()
相关文章推荐
- myeclipse python插件安装和环境配置(Windows7下)
- python IndentationError:
- ubuntu eclipse Python开发环境配置
- python定时任务调度库_apscheduler的使用(2)
- Flask Excel python操作excel
- python 线程相关 (七)
- Python 创建和发布安装函数模块
- Python 学习(3)---Python标准异常总结
- python 基础数据类型 (一)
- 小甲鱼Python笔记(下)
- python的soap模块扩展
- python2.7使用ansible
- python2.7使用ansible
- python2.7使用ansible
- python2.7使用ansible
- 用Python学习统计学基础-3
- python进行excel操作
- python 如何安装cffi
- 关于python下构建c模块出现error: Unable to find vcvarsall.bat问题的解决方法
- python日期