python的强大的原因就是有很多非常实用的模块。今天用到了一个读取文件内容的小模块,做个记录:
#!/usr/bin/python # -*- coding: utf-8 -*- import os, glob path = 'XXX' for infile in glob.glob(os.path.join(path, '*.png')): print infile print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") for infile in sorted(glob.glob(os.path.join(path, '*.png'))): print infile print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") for infile in sorted(glob.glob(os.path.join(path, '*.png')),key=os.path.getmtime): print infile
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") for infile in sorted(glob.glob(os.path.join(path, '*.png')),key=os.path.getsize): print infile