问题描述
os.stat返回st_mtime和st_ctime属性,在POSIX上,修改时间为st_mtime和st_ctime更改时间".是否有任何函数可以使用python和Linux在返回文件的创建时间?
os.stat returns st_mtime and st_ctime attributes, the modification time is st_mtime and st_ctime "change time" on POSIX.is there any function that return the creation time of a file using python and under Linux?
推荐答案
您不能-它不会存储在任何地方.文件的最后修改时间 时间(由"ls -l"显示),最后访问时间(由"ls -lu"显示) 和inode更改时间(由"ls -lc"显示).后者经常 称为创建时间"-甚至在某些手册页中- 但这是错误的;也可以通过mv,ln, chmod,chown和chgrp.
You can't - it isn't stored anywhere. Files have a last-modified time (shown by "ls -l"), a last-accessed time (shown by "ls -lu") and an inode change time (shown by "ls -lc"). The latter is often referred to as the "creation time" - even in some man pages - but that's wrong; it's also set by such operations as mv, ln, chmod, chown and chgrp.
"stat(2)"的手册页对此进行了讨论.
The man page for "stat(2)" discusses this.
这篇关于在Linux上使用Python获取文件创建时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!