Skip to Content
Python 技術手冊 第三版
book

Python 技術手冊 第三版

by lex Martelli, Anna Martelli Ravenscroft, Steve Holden
January 2018
Intermediate to advanced content levelIntermediate to advanced
856 pages
17h 17m
Chinese
GoTop Information, Inc.
Content preview from Python 技術手冊 第三版
346
|
10 章 檔案與文字作業
10-4  stat_result 實體的項目(屬性)
項目索引 屬性名稱 意義
0 st_mode 保護和其他的模式位元
1 st_ino Inode 號碼
2 st_dev 裝置 ID
3 st_nlink 硬連結數
4 st_uid 擁有者的使用者 ID
5 st_gid 擁有者的群組 ID
6 st_size 以位元組為單位的大小
7 st_atime 上次存取時間
8 st_mtime 上次修改時間
9 st_ctime 上次狀態變更時間
舉例來說,要以位元組為單位,印出檔案
path
的大小,你可以使用下列
任一個:
import os
print(os.path.getsize(path))
print(os.stat(path)[6])
print(os.stat(path).st_size)
時間值都是從 epoch(曆元)起算的秒數,如第 12 章中所涵蓋的(多數
平台上的
int
)。無法為一個項目給出一個有意義值的平台會使用一個虛
設(dummy)的值。
tempnam, tempnam(dir=None, prefix=None) tmpnam( )
tmpnam
回傳可用作一個新暫存檔的名稱的一個絕對路徑。
注意:
tempnam
tmpnam
是你程式安全性中的弱點。避免這些函式,改為
使用標準程式庫模組
tempfile
,涵蓋於前面的「tempfile 模組」中。
utime utime(path, times=None)
設定檔案或目錄
path
的存取與修改時間。如果 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

測試驅動開發|使用 Python

測試驅動開發|使用 Python

Harry J.W. Percival
Linux 内核观测技术BPF

Linux 内核观测技术BPF

David Calavera, Lorenzo Fontana

Publisher Resources

ISBN: 9789864766819