当前位置:首页 » 编程语言 » symlinkpython

symlinkpython

发布时间: 2024-12-22 01:56:55

python 有哪些方法可以获取到文件的创建时间

In [3]: os.stat('./sendmail.py')
Out[3]: posix.stat_result(st_mode=33204, st_ino=313029, st_dev=64769L, st_nlink=1, st_uid=500, st_gid=500, st_size=635, st_atime=1480821883, st_mtime=1480821926, st_ctime=1480821926)
取st_ctime

import os
def get_create_time(filename):
return os.stat(filename).st_ctime
update文档

os.stat(path)
Perform the equivalent of a stat() system call on the given path. (This function follows symlinks; to stat a symlink use lstat().)

The return value is an object whose attributes correspond to the members of the stat structure, namely:

st_mode - protection bits,
st_ino - inode number,
st_dev - device,
st_nlink - number of hard links,
st_uid - user id of owner,
st_gid - group id of owner,
st_size - size of file, in bytes,
st_atime - time of most recent access,
st_mtime - time of most recent content modification,
st_ctime - platform dependent; time of most recent metadata change on Unix, or the time of creation on Windows)
可见st_ctime确实可做为created_time, 修改时间取st_mtime

热点内容
java返回this 发布:2025-10-20 08:28:16 浏览:573
制作脚本网站 发布:2025-10-20 08:17:34 浏览:863
python中的init方法 发布:2025-10-20 08:17:33 浏览:561
图案密码什么意思 发布:2025-10-20 08:16:56 浏览:743
怎么清理微信视频缓存 发布:2025-10-20 08:12:37 浏览:663
c语言编译器怎么看执行过程 发布:2025-10-20 08:00:32 浏览:983
邮箱如何填写发信服务器 发布:2025-10-20 07:45:27 浏览:233
shell脚本入门案例 发布:2025-10-20 07:44:45 浏览:92
怎么上传照片浏览上传 发布:2025-10-20 07:44:03 浏览:785
python股票数据获取 发布:2025-10-20 07:39:44 浏览:691