python使用os模块的os.walk遍历文件夹示例
(福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun)
#-*- coding:utf-8 -*-
import os
if __name__ == '__main__':
try:
'''traval and list all files and all dirs'''
for root, dirs, files in os.walk('D:' + os.sep + 'Python27'):
print '-------------------directory < ' + root + ' > --------------------------'
for d in dirs:
print d
for f in files:
print f
except OSError, e:
print os.strerror(e.errno)
相关文章
python使用 HTMLTestRunner.py生成测试报告
这篇文章主要介绍了python使用 HTMLTestRunner.py生成测试报告 ,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2017-10-10anaconda?部署Jupyter?Notebook服务器过程详解
这篇文章主要为大家介绍了anaconda?部署Jupyter?Notebook服务器过程详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2022-09-09
最新评论