2016年4月20日 星期三

[python] Ubuntu, python 3.x list files under folder , list modify time , create time of files. 列出資料夾下的檔案list, 和修改時間或其他屬性

import os,time



file_list=os.listdir("/home/xxxxxx/Desktop")
#print(file_list)


for file in file_list:
    if '~'  in file:
        file_list.remove(file)

print(file_list)

for file in file_list:
    (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime) = os.stat(file)
    print (file,"\nlast modified: %s" % time.ctime(mtime),'\nCreate time   ',time.ctime(ctime),'\n')

沒有留言:

張貼留言