python获取文件创建时间_python 有哪些方法可以获取到文件的创建时间

In [3]: os.stat('./sendmail.py')

Out[3]: posix.stat_result(st_mode=33204, st_ino=313029, st_dev=64769L, st_nlink=1, st_uid=500, st_gid=500, st_size=635, st_atime=1480821883, st_mtime=1480821926, st_ctime=1480821926)

取st_ctime

import os

def get_create_time(filename):

return os.stat(filename).st_ctime

update

文档

os.stat(path)

Perform the equivalent of a stat() system call on the given path. (This function follows symlinks; to stat a symlink use lstat().)

The return value is an object whose attributes correspond to the members of the stat structure, namely:

st_mode - protection bits,

st_ino - inode number,

st_dev - device,

st_nlink - number of hard links,

st_uid - user id of owner,

st_gid - group id of owner,

st_size - size of file, in bytes,

st_atime - time of most recent access,

st_mtime - time of most recent content modification,

st_ctime - platform dependent; time of most recent metadata change on Unix, or the time of creation on Windows)

可见st_ctime确实可做为created_time, 修改时间取st_mtime

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值