【发布时间】:2016-12-14 22:28:07
【问题描述】:
我试图获得微秒,但最后三位数字始终为 0,所以我想我只能获得毫秒。 这是操作系统问题吗?我在 Win7x64 上使用 Python 2.7.10。 难道我做错了什么?否则我将如何获得微秒?
>>> import datetime
>>> datetime.datetime.now()
datetime.datetime(2016, 8, 9, 4, 33, 28, 504000)
这不是重复
Using %f with strftime() in Python to get microseconds
因为这种方法最后给了我相同的零。
【问题讨论】:
-
可能是操作系统问题;在 LMDE Betsy (Linux) 64 位和 Python 2.7.9 上,我可以得到微秒:
datetime.datetime(2016, 8, 9, 12, 46, 14, 209624) -
这是
OS X使用 Python 2.7.10 的输出:datetime.datetime(2016, 8, 8, 19, 49, 23, 952833)。在 Windoze 中,我得到datetime.datetime(2016, 8, 8, 19, 49, 23, 952000)... 所以我会说 Fred 做到了。