python 文件操作 练习:取得文件的最后存取时间

#coding=utf-8

import os
import time

file_atime=int(os.path.getatime('d:\\a.txt'))
print "file_atime:",file_atime
time_arr=time.localtime(file_atime)
print 'time_arr:',time_arr

print "regular time:",time.strftime('%Y-%m-%d %H:%M:%S',time_arr)


c:\Python27\Scripts>python task_test.py
file_atime: 1522027881
time_arr: time.struct_time(tm_year=2018, tm_mon=3, tm_mday=26, tm_hour=9, tm_min=31, tm_sec=21, tm_wday=0, tm_yday=85, tm_isdst=0)
regular time: 2018-03-26 09:31:21

posted @ 2018-04-20 13:55  夏晓旭  阅读(557)  评论(0)    收藏  举报