地址:http://docs.python.org/library/datatypes.html
Python提供的一些数据类型。
暂时越过的模块:
- 9.4. heapq — Heap queue algorithm
- 9.5. bisect — Array bisection algorithm
- 9.6. array — Efficient arrays of numeric values
- 9.7. sets — Unordered collections of unique elements
- 9.9. mutex — Mutual exclusion support
- 9.10. queue — A synchronized queue class
- 9.11. weakref — Weak references
- 9.12. UserDict — Class wrapper for dictionary objects
- 9.13. UserList — Class wrapper for list objects
- 9.14. UserString — Class wrapper for string objects
- 9.15. types — Names for built-in types
- 9.16. new — Creation of runtime internal objects
- 9.17. copy — Shallow and deep copy operations
- 9.18. pprint — Data pretty printer
- 9.19. repr — Alternate repr() implementation
9.1 datetime
2009年6月6日8:01:28
地址:http://docs.python.org/library/datetime.html
时间对象分为知道和不知道时区的两类。
模块下的类型有data、time、datetime、timedelta和tzinfo。
>>> import datetime
>>> t = datetime.date.today()
>>> t
datetime.date(2009, 6, 6)
>>> t.day
6
>>> another = datetime.date(2009, 8, 8)
>>> d = another - t
>>> d
datetime.timedelta(63)
>>> d.days
63
>>> d.seconds
0
>>> t.isoformat()
'2009-06-06'
>>> t.strftime('%a')
'Sat'
>>> t.strftime('%A')
'Saturday'
>>> t.strftime('year:%y, month:%m, day:%d, %a.')
'year:09, month:06, day:06, Sat.'
>>>