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 技術手冊 第三版
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.

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

測試驅動開發|使用 Python

Harry J.W. Percival

Publisher Resources

ISBN: 9789864766819