# 遍历指定目录,显示目录下的所有文件名
def eachFile(filepath):
pathDir = os.listdir(filepath)
file_list=[]
for allDir in pathDir:
child = os.path.join('%s%s' % (filepath, allDir))
file_list.append(child)
# print (child) # .decode('gbk')是解决中文显示乱码问题
return file_list
返回一个列表
读取每个文件,需要循环遍历