Answers for "datetime.datetime has no attribute datetime"

4

datetime has no attribute now

#You probably have

import datetime

#change that to

from datetime import datetime
Posted by: Guest on June-20-2020
0

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

# Use either
import datetime
datetime.datetime.timedelta()
# or
from datetime import datetime
datetime.timedelta()
# But do not use (as you currently are):
from datetime import datetime
datetime.datetime.timedelta()
Posted by: Guest on April-19-2021
0

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

>>> from datetime import datetime
>>> datetime
<type 'datetime.datetime'>
>>> datetime.datetime(2001,5,1) # You shouldn't expect this to work 
                                # as you imported the type, not the module
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'
>>> datetime(2001,5,1)
datetime.datetime(2001, 5, 1, 0, 0)
Posted by: Guest on October-15-2021

Code answers related to "datetime.datetime has no attribute datetime"

Python Answers by Framework

Browse Popular Code Answers by Language