数据类型¶
本章所描述的模块提供了许多专门的数据类型,如日期和时间、固定类型的数组、堆队列、双端队列、以及枚举。
Python也提供一些内置数据类型,特别是,dict
、 list
、set
、frozenset
、以及 tuple
。str
这个类是用来存储Unicode字符串的,而 bytes
和 bytearray
这两个类是用来存储二进制数据的。
本章包含以下模块的文档:
datetime
--- 基本日期和时间类型- 感知型对象和简单型对象
- 常量
- 有效的类型
timedelta
类对象date
对象date
date.today()
date.fromtimestamp()
date.fromordinal()
date.fromisoformat()
date.fromisocalendar()
date.min
date.max
date.resolution
date.year
date.month
date.day
date.replace()
date.timetuple()
date.toordinal()
date.weekday()
date.isoweekday()
date.isocalendar()
date.isoformat()
date.__str__()
date.ctime()
date.strftime()
date.__format__()
date
用法示例
datetime
对象datetime
datetime.today()
datetime.now()
datetime.utcnow()
datetime.fromtimestamp()
datetime.utcfromtimestamp()
datetime.fromordinal()
datetime.combine()
datetime.fromisoformat()
datetime.fromisocalendar()
datetime.strptime()
datetime.min
datetime.max
datetime.resolution
datetime.year
datetime.month
datetime.day
datetime.hour
datetime.minute
datetime.second
datetime.microsecond
datetime.tzinfo
datetime.fold
datetime.date()
datetime.time()
datetime.timetz()
datetime.replace()
datetime.astimezone()
datetime.utcoffset()
datetime.dst()
datetime.tzname()
datetime.timetuple()
datetime.utctimetuple()
datetime.toordinal()
datetime.timestamp()
datetime.weekday()
datetime.isoweekday()
datetime.isocalendar()
datetime.isoformat()
datetime.__str__()
datetime.ctime()
datetime.strftime()
datetime.__format__()
- 用法示例:
datetime
time
对象tzinfo
对象timezone
对象strftime()
和strptime()
的行为
zoneinfo
--- IANA 时区支持calendar
--- 日历相关函数Calendar
Calendar.iterweekdays()
Calendar.itermonthdates()
Calendar.itermonthdays()
Calendar.itermonthdays2()
Calendar.itermonthdays3()
Calendar.itermonthdays4()
Calendar.monthdatescalendar()
Calendar.monthdays2calendar()
Calendar.monthdayscalendar()
Calendar.yeardatescalendar()
Calendar.yeardays2calendar()
Calendar.yeardayscalendar()
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
--- 堆队列算法bisect
--- 数组二分查找算法array
--- 高效的数字数组typecodes
array
array.typecode
array.itemsize
array.append()
array.buffer_info()
array.byteswap()
array.count()
array.extend()
array.frombytes()
array.fromfile()
array.fromlist()
array.fromunicode()
array.index()
array.insert()
array.pop()
array.remove()
array.reverse()
array.tobytes()
array.tofile()
array.tolist()
array.tounicode()
weakref
--- 弱引用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
CapsuleType
- 附加工具类和函数
- 协程工具函数
copy
--- 浅层 (shallow) 和深层 (deep) 复制操作pprint
--- 数据美化输出reprlib
--- 另一种repr()
实现enum
--- 对枚举的支持graphlib
--- 操作类似图的结构的功能