Linux下使用st_ctime近似获取文件的创建时间,适用于文件创建后不发生任何变化的情况
filectime = os.stat(strUrl+filename).st_ctime
datetime.datetime.fromtimestamp(filectime).strftime('%Y-%m-%d-%H-%M-%S-%f')The field st_ctime is changed by writing or by setting inode information (i.e., owner, group, link count, mode, etc.). http://linux.die.net/man/2/stat
http://stackoverflow.com/questions/1408272/get-file-creation-time-with-python-on-linux
http://stackoverflow.com/questions/12400256/python-converting-epoch-time-into-the-datetime#
本文介绍了如何在Linux系统中使用Python的os模块获取文件的创建时间,并解释了st_ctime字段的变化原因,同时提供了将时间戳转换为可读日期格式的方法。

被折叠的 条评论
为什么被折叠?



