Amj*_*jad 1 python runtime-error attributeerror python-3.x python-datetime
我正在使用Python 3.7并尝试datetime从库中学习模块,但是我正在获取AttributeError。下面的代码:
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)
Run Code Online (Sandbox Code Playgroud)
作为运行文件,我得到此错误 AttributeError: module 'datetime' has no attribute 'time'
请帮助我找到我要去的地方。谢谢
小智 5
问题可能是您的python文件与datetime模块具有相同的名称,也许您将其称为程序文件datetime.py。
您需要重命名程序文件并删除路径中生成的任何最终的.pyc文件,然后才能导入正确的datetime模块。
| 归档时间: |
|
| 查看次数: |
663 次 |
| 最近记录: |