Fork me on GitHub

  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

 

posted on 2018-05-10 11:10  虚生  阅读(600)  评论(0编辑  收藏  举报