Difference between python - getmtime() and getctime() in unix system

后端 未结 3 789
终归单人心
终归单人心 2020-12-09 08:43

Can someone please specify what is the difference between os.path.getmtime(path) and os.path.getctime(path) in unix systems . As per the defnition

3条回答
  •  伪装坚强ぢ
    2020-12-09 09:08

    From the man page on stat, which os.path.getmtime() and os.path.getctime() both use on Unix systems:

    The field st_mtime is changed by file modifications, for example, by mknod(2), truncate(2), utime(2) and write(2) (of more than zero bytes). Moreover, st_mtime of a directory is changed by the creation or deletion of files in that directory. The st_mtime field is not changed for changes in owner, group, hard link count, or mode.
    ...

    The field st_ctime is changed by writing or by setting inode information (i.e., owner, group, link count, mode, etc.).

    So no, these are not the same.

提交回复
热议问题