python 遍历一个文件夹下所有文件名称
发布时间
阅读量:
阅读量
_用python 遍历一个文件夹下所有文件名称_
_可以用字典的方式,程序可参考程序“E:\untitled\weather\extact_copy.py ”
#coding=utf-8
_**import****import****"E: \ weather_data\ pressure\ data_before" **_# 指明被遍历的文件夹
_**for** filenames**in** _# 三个参数:分别返回1.父目录 2.所有文件夹名字(不含路径) 3.所有文件名字
_**for****in** _# 输出文件夹信息
_**print "parent is:" ****print "dirname is" ****for****in** filenames _# 输出文件信息
_**print "parent is:" ****print "filename is:" ****print "the full name of the file is:" **_# 输出文件路径信息_
注意:要想python自动读取文件夹下所有文件内容,可以借助字典
全部评论 (0)
还没有任何评论哟~
