python 简单遍历文件...
来源:互联网 发布:软件测试和网络工程师 编辑:程序博客网 时间:2024/06/04 18:49
import os
if os.path.isdir(path):
for file in os.listdir(path):
file_path = os.path.join(path, file)
for sub_file in walk(file_path):
yield sub_file
else:
yield path
for file in walk("/home/long"):
print file
这里利用了迭代器.
if os.path.isdir(path):
for file in os.listdir(path):
file_path = os.path.join(path, file)
for sub_file in walk(file_path):
yield sub_file
else:
yield path
for file in walk("/home/long"):
print file
- python 简单遍历文件...
- Python之简单文件目录遍历
- Python遍历文件树
- Python学习 文件遍历
- python 遍历文件
- Python, Shell 遍历文件
- python 文件目录遍历
- python 文件遍历
- python 文件遍历
- Python循环遍历文件
- Python遍历文件
- python遍历文件目录
- python 遍历文件夹 文件
- python遍历文件目录
- python 遍历文件
- python遍历文件
- python遍历目录文件
- Python遍历文件树
- Profile小试
- 使用JasperReport+iReport进行WEB开发
- javascript event详解
- 2012年8月28日 学习总结
- GAS(GNU ASM)汇编概述
- python 简单遍历文件...
- 结构体对齐问题
- UVA 465 溢出
- 现实与理想(中国台湾清华大学教授彭明辉)
- poj2379 Sum of Consecutive Prime Numbers(水)
- 我与你一起学习JSP(三)——JSP的基础语法【一】
- rtsp学习
- 持续集成学习笔记-入门篇(2)持续集成工具选择
- 【面试笔试-php】某公司php方向面试题总结。