資料型別¶
本章節所描述的模組 (module) 提供了多樣的專門資料型別,例如日期與時間、固定型別陣列 (fixed-type arrays)、堆積佇列 (heap queues)、雙端佇列 (double-ended queues) 與列舉 (enumerations)。
Python 也有提供一些內建資料型別,特別是 dict
、list
、set
與 frozenset
和 tuple
。str
類別是用來儲存 Unicode 字串,bytes
與 bytearray
類別則是用來儲存二進位制資料。
本章節包含下列模組的文件:
datetime
--- 日期與時間的基本型別- Aware and Naive Objects
- 常數
- Available Types
timedelta
物件date
物件datetime
物件datetime
today()
now()
utcnow()
fromtimestamp()
utcfromtimestamp()
fromordinal()
combine()
fromisoformat()
fromisocalendar()
strptime()
min
max
resolution
year
month
day
hour
minute
second
microsecond
tzinfo
fold
date()
time()
timetz()
replace()
astimezone()
utcoffset()
dst()
tzname()
timetuple()
utctimetuple()
toordinal()
timestamp()
weekday()
isoweekday()
isocalendar()
isoformat()
__str__()
ctime()
strftime()
__format__()
- 用法範例:
datetime
time
物件tzinfo
物件timezone
物件strftime()
與strptime()
的行為
zoneinfo
--- IANA 時區支援calendar
--- 日曆相關函式Calendar
TextCalendar
HTMLCalendar
LocaleTextCalendar
LocaleHTMLCalendar
setfirstweekday()
firstweekday()
isleap()
leapdays()
weekday()
weekheader()
monthrange()
monthcalendar()
prmonth()
month()
prcal()
calendar()
timegm()
day_name
day_abbr
MONDAY
TUESDAY
WEDNESDAY
THURSDAY
FRIDAY
SATURDAY
SUNDAY
Day
month_name
month_abbr
JANUARY
FEBRUARY
MARCH
APRIL
MAY
JUNE
JULY
AUGUST
SEPTEMBER
OCTOBER
NOVEMBER
DECEMBER
Month
IllegalMonthError
IllegalWeekdayError
- 命令列用法
collections
--- 容器資料型態collections.abc
--- 容器的抽象基底類別heapq
--- 堆積佇列 (heap queue) 演算法bisect
--- 陣列二分演算法 (Array bisection algorithm)array
--- 高效率的數值型陣列weakref
--- 弱參照types
--- 動態型別建立與內建型別名稱- Dynamic Type Creation
- Standard Interpreter Types
NoneType
FunctionType
LambdaType
GeneratorType
CoroutineType
AsyncGeneratorType
CodeType
CellType
MethodType
BuiltinFunctionType
BuiltinMethodType
WrapperDescriptorType
MethodWrapperType
NotImplementedType
MethodDescriptorType
ClassMethodDescriptorType
ModuleType
EllipsisType
GenericAlias
UnionType
TracebackType
FrameType
GetSetDescriptorType
MemberDescriptorType
MappingProxyType
- Additional Utility Classes and Functions
- Coroutine Utility Functions
copy
--- 淺層 (shallow) 和深層 (deep) 複製操作pprint
--- 資料美化列印器reprlib
---repr()
的替代實作enum
--- 對列舉的支援graphlib
—-- 使用類圖 (graph-like) 結構進行操作的功能