Python Cookbook学习记录 ch2_9/16_2013/10/28
2013-10-28 22:10
393 查看
2.9 从zip文件中读取数据
可以通过Python标准库提供的zipfile模块访问zip压缩文件
2.16 遍历目录树
使用os.walk可以便利目录树
可以通过Python标准库提供的zipfile模块访问zip压缩文件
>>> import zipfile >>> z = zipfile.ZipFile('test.zip','r') >>> for filename in z.namelist(): print 'File:', filename File: wex.txt File: 1.txt File: a.txt
2.16 遍历目录树
使用os.walk可以便利目录树
>>> for root, dirs, files in os.walk("E:\PythonCookbook\\"): print root,dirs,files E:\PythonCookbook\ ['CHA2', 'CHA3'] [] E:\PythonCookbook\CHA2 [] ['abinfile', 'thefile.txt'] E:\PythonCookbook\CHA3 [] ['1.py', 'countWorkdays.py', 'findlastFriday.PY', 'test.zip']
相关文章推荐
- Python Cookbook学习记录 ch4_8-16_2013/11/2
- Python Cookbook学习记录 ch2_2_2013/10/27
- Python Cookbook学习记录 ch2_4/5_2013/10/27
- Python Cookbook学习记录 ch2_3_2013/10/27
- Python Cookbook学习记录 ch2_1_2013/10/27
- Python Cookbook学习记录 ch2_6/7/8_2013/10/27
- Python Cookbook学习记录 ch1_17_2013/10/25
- Python Cookbook学习记录 ch1_1_2013/10/20
- Python Cookbook学习记录 ch1_3_2013/10/21
- Python Cookbook学习记录 ch1_19_2013/10/27
- Python Cookbook学习记录 ch4_6/7_2013/11/2
- Python Cookbook学习记录 ch1_12_2013/10/24
- Python Cookbook学习记录 ch3_3/4_2013/10/29
- Python Cookbook学习记录 ch1_5_2013/10/22
- Python Cookbook学习记录 ch3_10/11_2013/10/30
- Python Cookbook学习记录 ch1_6_2013/10/22
- Python Cookbook学习记录 ch6_2_2013/11/7
- Python Cookbook学习记录 ch1_9_2013/10/23
- Python Cookbook学习记录 ch6_1_2013/11/6
- Python Cookbook学习记录 ch6_3_2013/11/7