I am using Python 3.7 and trying to learn datetime module from library, but I am getting AttributeError. code below:
import datetime
t = datetime.time(4, 20, 1)
# Let's show the different components
print(t)
print('hour :', t.hour)
print('minute:', t.minute)
print('second:', t.second)
print('microsecond:', t.microsecond)
print('tzinfo:', t.tzinfo)
As run file I get this error AttributeError: module 'datetime' has no attribute 'time'
Please Help me to find where I am going wrong. Thanks
The problem may be that your python file has the same name as the datetime module, maybe you called your program file datetime.py.
You need to rename your program file and delete any eventual .pyc file generated in your path, then you can import the correct datetime module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With