Python 遍历文件查找不同
2015-08-30 02:11
621 查看
<span style="font-size:18px;">import os arr1 = [] path = '.\\' def fun(dir,arr): i = 0 j = 0 for t in os.listdir(dir): t1 = os.path.join(dir,t) if os.path.isfile(t1): arr.append((t,t1)) elif os.path.isdir(t1): fun(t1,arr) f = open('.\\result.txt','w') fun(path,arr1) arr1.sort() for i in range(0,len(arr1)-1): if arr1[i][0] != os.path.basename(__file__) and arr1[i][0] != 'result.txt': print('{0:-<50}'.format(arr1[i][0]),arr1[i][1],file = f) f.close() print('over!')</span>
相关文章推荐
- 初探python的__init__.py
- 简单Python脚本实现数据导出Excel格式的尝试
- 【python】strip()的用法
- 【python】socket编程常量错误问题-1 'AF_INET'
- 2015/8/29 Python基础(3):数值
- Python 自学笔记(二)第一个程序 Hello World
- Python中文分词组件jieba
- Python 2.7和NLTK安装教程
- python使用xmlrunner模块生成报告举例
- Python 自学笔记(一)环境搭建
- Setup Python 开发环境和IPython的基本使用
- 零基础学python-9.2 文件
- 零基础学python-9.2 文件
- python常用函数
- python字符串操作
- python学习笔记10
- 关于python文件操作
- Python计算代码段的时间
- python set集合
- 零基础学python-9.1 元组