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

Python 技術手冊 第三版

by lex Martelli, Anna Martelli Ravenscroft, Steve Holden
January 2018
Intermediate 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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

利用 Python 进行数据分析(原书第2版)

利用 Python 进行数据分析(原书第2版)

Wes McKinney

Publisher Resources

ISBN: 9789864766819