Get file creation time with Python on linux

后端 未结 7 1905
一向
一向 2020-12-16 11:31

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 tim

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-16 12:06

    try:

    st_birthtime
    

    It isnt' guaranteed to be available on all systems though. From the docs:

    On some Unix systems (such as Linux), the following attributes may also be available: st_blocks (number of blocks allocated for file), st_blksize (filesystem blocksize), st_rdev (type of device if an inode device). st_flags (user defined flags for file).

    On other Unix systems (such as FreeBSD), the following attributes may be available (but may be only filled out if root tries to use them): st_gen (file generation number), st_birthtime (time of file creation).

    http://docs.python.org/2/library/os.html#os.stat

提交回复
热议问题