类型对象“datetime.datetime"没有属性“datetime"

2022-01-14 00:00:00 python datetime namespaces

问题描述

我收到以下错误:

类型对象'datetime.datetime'没有属性'datetime'

type object 'datetime.datetime' has no attribute 'datetime'

在下面一行:

date = datetime.datetime(int(year), int(month), 1)

有人知道错误的原因吗?

Does anybody know the reason for the error?

如果有帮助,我使用 from datetime import datetime 导入日期时间

I imported datetime with from datetime import datetime if that helps

谢谢


解决方案

适用于python 3.3

For python 3.3

from datetime import datetime, timedelta
futuredate = datetime.now() + timedelta(days=10)

相关文章