os.path.getmtime(path)Return the time of last modification of path. The return value is a number giving the number of seconds since the epoch (see thetime module). Raise os.error if the file does not exist or is inaccessible.这是文档原文,试了一下,返回了一个极大的数,搞不太懂这个函数什么意思,有什么用呢?
2 回答

慕田峪4524236
TA贡献1875条经验 获得超5个赞
这是一个unix时间戳。可以使用datetime库来处理时间戳:
import datetime, os t = os.path.getmtime( '/' ) tt = datetime.datetime.fromtimestamp(t) ttt = tt.strftime( '%Y' ) # 这是个时间格式化字符串,只能返回年份。 |
添加回答
举报
0/150
提交
取消