官方文档
http://python.usyiyi.cn/translate/python_352/library/datetime.html
代码示例
from datetime import datetime now = datetime.now() print("年:%s" % now.year) print("月:%s" % now.month) print("日:%s" % now.day) print("时:%s" % now.hour) print("分:%s" % now.minute) print("秒:%s" % now.second) print("毫秒:%s" % now.microsecond) print("星期:%s" % now.weekday()) # 星期一到星期日 0-6 print("星期:%s" % now.isoweekday()) # 星期一到星期日 1-7 print("日期:%s" % now.date()) print("时间:%s" % now.time()) print("公里序数:%s" % now.toordinal()) # 00001年1月1日的公里序数是1,00001年1月2日的公里序数是2