Data Types¶
本章所描述的模块提供了许多专门的数据类型,如日期和时间、固定类型的数组、堆队列、双端队列、以及枚举。
Python也提供一些内置数据类型,特别是,dict、 list、set、frozenset、以及 tuple。str 这个类是用来存储Unicode字符串的,而 bytes 和 bytearray 这两个类是用来存储二进制数据的。
The following modules are documented in this chapter:
datetime--- Basic date and time typescalendar--- General calendar-related functionscollections--- 容器資料型態collections.abc--- Abstract Base Classes for Containersheapq--- 堆積佇列 (heap queue) 演算法bisect--- 陣列二分演算法 (Array bisection algorithm)array--- 高效率的數值型態陣列weakref--- Weak referencestypes--- Dynamic type creation and names for built-in typescopy--- Shallow and deep copy operationspprint--- Data pretty printerreprlib--- Alternaterepr()implementationenum--- Support for enumerations- Module Contents
- Creating an Enum
- Programmatic access to enumeration members and their attributes
- Duplicating enum members and values
- Ensuring unique enumeration values
- Using automatic values
- Iteration
- Comparisons
- Allowed members and attributes of enumerations
- Restricted Enum subclassing
- Pickling
- Functional API
- Derived Enumerations
- When to use
__new__()vs.__init__() - Interesting examples
- How are Enums different?
