import os
DIR = "/home/serho/workspace/lisp"
def compare(x, y):
stat_x = os.stat(DIR + "/" + x)
stat_y = os.stat(DIR + "/" + y)
if stat_x.st_ctime < stat_y.st_ctime:
return -1
elif stat_x.st_ctime > stat_y.st_ctime:
return 1
else:
return 0
iterms = os.listdir(DIR)
iterms.sort(compare)
for iterm in iterms:
print iterm
本文转自 chengxuyonghu 51CTO博客,原文链接:http://blog.51cto.com/6226001001/1766291,如需转载请自行联系原作者