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

熱點內容
頑固的緩存 發布:2025-07-01 03:28:23 瀏覽:114
u盤插安卓手機上怎麼加密 發布:2025-07-01 03:09:19 瀏覽:90
php記住我 發布:2025-07-01 02:58:51 瀏覽:392
流媒體伺服器搭建php 發布:2025-07-01 02:54:24 瀏覽:371
我的世界伺服器地板方塊 發布:2025-07-01 02:41:35 瀏覽:564
魔域伺服器爆滿怎麼進 發布:2025-07-01 02:31:42 瀏覽:739
c語言統計字元出現的次數 發布:2025-07-01 02:27:24 瀏覽:242
江鈴福特主要有哪些車型以及配置 發布:2025-07-01 02:23:10 瀏覽:25
格式化資料庫 發布:2025-07-01 02:15:03 瀏覽:267
蘇州資料庫 發布:2025-07-01 02:09:25 瀏覽:617