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

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:572
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:860
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:559
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:740
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:660
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:981
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:232
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:90
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:783
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:688