为何这个代码跑不过?
from datetime import datetimea= datetime.now()
dt1=a+datetime.timedelta(hours=1)
print(dt1)
提示:
Traceback (most recent call last):
File "E:/pyhton/random_walk.py", line 3, in <module>
dt1=a+datetime.timedelta(hours=1)
AttributeError: type object 'datetime.datetime' has no attribute 'timedelta'
import datetime
a= datetime.datetime.now()
dt1=a+datetime.timedelta(hours=1)
print(dt1)
datetime模块下面有5大类 (抽象类tzinfo就不说了)
datetime.timedelta 时间间隔类
datetime.timezone 时区信息类
datetime.date 简单型日期类
datetime.time 时间类
datetime.datetime date类的子类,日期时间类
页:
[1]