當前位置:首頁 » 編程語言 » 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

熱點內容
本地電腦怎麼用伺服器ip 發布:2025-07-01 09:10:03 瀏覽:827
有趣的python代碼 發布:2025-07-01 09:10:02 瀏覽:357
威龍奇兵ftp 發布:2025-07-01 09:07:38 瀏覽:691
linuxedit 發布:2025-07-01 09:03:36 瀏覽:421
跑分平台腳本 發布:2025-07-01 08:40:17 瀏覽:599
手機上的中文編程軟體 發布:2025-07-01 08:39:13 瀏覽:821
7z解壓縮linux 發布:2025-07-01 08:37:47 瀏覽:320
sybase資料庫字元集 發布:2025-07-01 08:37:03 瀏覽:348
php家教網 發布:2025-07-01 08:34:41 瀏覽:289
上傳完畢聲音 發布:2025-07-01 08:33:17 瀏覽:393