use*_*123 4 python error-handling datetime attributeerror
我在python中编写脚本,我需要知道代码中两点之间有多少毫秒.
程序启动时我有一个全局变量:
from datetime import datetime
a=datetime.now()
Run Code Online (Sandbox Code Playgroud)
当我需要知道已经过了多少毫秒时,我执行这个:
b=datetime.now()
print (b.microseconds-a.microseconds)*1000
Run Code Online (Sandbox Code Playgroud)
但是我收到此错误:
AttributeError: 'datetime.datetime' object has no attribute 'microseconds'
Run Code Online (Sandbox Code Playgroud)
怎么了?我怎样才能解决这个问题?