python获取文件的创建时间

来源:互联网 发布:研发生产销售 知乎 编辑:程序博客网 时间:2024/04/20 02:00
Linux下使用st_ctime近似获取文件的创建时间,适用于文件创建后不发生任何变化的情况
filectime = os.stat(strUrl+filename).st_ctimedatetime.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#

0 0