path = '/some/path/to/file'
for filename in os.listdir(path):
# do your stuff
for filename in os.listdir(os.getcwd()): 取出的文件夹的名称是随机的,并不是按照一定顺序
for filename in glob.glob(os.path.join(path, '*.txt')):(获取的文件名称也是随机的)
# do your stuff
for filename in glob.glob('*.txt'):
for data_file in sorted(os.listdir(folder_path)):(按照一定顺序读取文件)
print data_file