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 技術手冊 第三版
414
|
12 章 時間作業
timezone timezone
本地時區(沒有 DST)與 UTC 的偏移量(在美洲
>0
;在大部分的歐洲、
亞洲和非洲則
<=0
),以秒為單位。
tzname tzname
一對取決於 locale 的字串,分別是帶有及不帶有 DST 的本地時區名稱。
a
mktime
結果的小數部分永遠為 0,因為它的 timetuple 引數並不計入小數的秒數。
datetime 模組
datetime
提供類別來建立日期與時間物件,它們可以是能
察覺
aware
時區的,或
無知
naive
的(預設值)。其實體代表時區的類別
tzinfo
抽象的:模組
datetime
不提供實作(細節請參閱線上文件(
https://docs.
python.org/3/library/datetime.html#tzinfo-objects
))。
tzinfo
的良好、簡單的
實作,請參閱模組
pytz
(涵蓋於後面的「pytz 模組」),它可以讓你輕易地
創建能察覺時區的
datetime
物件。
datetime
中的所有型別都有不可變的實
體(immutable instances):屬性是唯讀的,而實體可以是一個
dict
中的鍵
值,或一個
set
中的項目。
date 類別
date
類別的實體代表一個日期(該日期中沒有當日時間),永遠都是原生
的,並假設用的是公曆(Gregorian calendar)。
date
實體有三個唯讀的整
數屬性:
year
month
day
date date(year,month,day
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