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 技術手冊 第三版
409
12
時間作業
一個 Python 程式能以數種方式處理時間。時間間隔(time intervals)是以
秒為單位的浮點數(幾分之一秒就是該間隔的小數部分):接受一個引數
表示以秒計算的一個時間間隔的所有標準程式庫函式都接受一個浮點數作
為那個引數的值。時間中的某個時間點(instants)是以從一個參考時間點
reference instant)開始計算的秒數來表示,這個參考時間點叫做
epoch
曆元
1970 1 1 UTC 時間的子夜,是 Unix Windows 平台上都
使用的 epoch。)時間點通常也需要以混合的時間單位表示(例如年、月、
日、小時、分鐘,以及秒),特別是用於 I/O 時。I/O,當然也需要將時間與
日期格式化為人類可讀字串的能力,並且能夠從字串格式剖析回來。
本章涵蓋
time
模組,它支援 Python 核心的時間處理功能性。
time
模組有
點仰賴底層系統的 C 程式庫。本章也介紹 Python 標準程式庫的
datetime
sched
calendar
模組,以及第三方的模組
dateutil
pytz
time 模組
底層的 C 程式庫決定了
time
模組能夠處理的日期範圍。在 Unix 系統
上,1970 年與 2038 年是典型的分界點,這是
datetime
避開的限制。時
間間隔通常以 UTCCoordinated Universal Time,一度被稱為 GMT,或
Greenwich Mean Time)指定。
time
模組也支援本地時區和日光節約時間 ...
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