AttributeError: type object 'datetime.datetime' has no attribute 'datetime'
时间: 2023-09-11 14:06:22 浏览: 202
the string was not recognized as a valid Datetime.
5星 · 资源好评率100%
This error occurs when you try to access the attribute 'datetime' on the class 'datetime.datetime'. This is not a valid attribute because 'datetime' is already the name of the class.
To fix this error, you can simply remove the redundant 'datetime' attribute and use the class name directly. For example:
```
import datetime
dt = datetime.datetime.now()
```
In this example, we are accessing the 'now' attribute of the 'datetime' class directly, without using the redundant 'datetime' attribute.
阅读全文