当前第2页 返回上一页
案例实践:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #endcoding: utf-8
# 获取文件的时间属性
# 用到的知识
# os. getcwd () 方法用于返回当前工作目录
# os.path.getatime(file) 输出文件访问时间
# os.path.getctime(file) 输出文件的创建时间
# os.path.getmtime(file) 输出文件最近修改时间
import time
import os
def fileTime(file):
return [
time.ctime(os.path.getatime(file)),
time.ctime(os.path.getmtime(file)),
time.ctime(os.path.getctime(file))
]
times = fileTime(os. getcwd ())
print (times)
print (type(times))
|
以上就是如何获取一个文件的创建和修改时间的详细内容,更多文章请关注木庄网络博客!!
返回前面的内容
相关阅读 >>
Python怎么建立空列表
Python 矩阵增加一行或一列的实例_Python
Python的numpy数组怎么合并
实用自动化运维Python脚本分享
Python如何配置清华镜像源
Python与scikit-learn的机器学习探索详解
Python中time的基本介绍
Python学来干什么
Python中x[::]什么意思
如何在shell脚本中检查Python版本?
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » 如何获取一个文件的创建和修改时间