當前位置:首頁 » 編程語言 » symlinkpython

symlinkpython

發布時間: 2024-12-22 01:56:55

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

熱點內容
oracle存儲過程筆試題 發布:2025-03-12 09:21:58 瀏覽:379
安卓之父的手機有什麼 發布:2025-03-12 09:12:11 瀏覽:967
下載電子普票讓寫伺服器地址 發布:2025-03-12 09:10:43 瀏覽:737
php過濾所有html標簽 發布:2025-03-12 09:09:22 瀏覽:841
家中裝修電表箱內開關如何配置 發布:2025-03-12 09:09:13 瀏覽:666
內網外網同時訪問 發布:2025-03-12 08:53:13 瀏覽:747
安卓手機為什麼卡頓解決方法 發布:2025-03-12 08:46:34 瀏覽:394
王者榮耀伺服器為什麼爆了 發布:2025-03-12 08:45:57 瀏覽:417
加密方式表 發布:2025-03-12 08:37:18 瀏覽:923
汽車貸款演算法 發布:2025-03-12 08:37:18 瀏覽:634