开发者

python time(milli seconds) calculation

开发者 https://www.devze.com 2022-12-14 13:24 出处:网络
How to calculate milliseconds,from the code below. a = datetime.datetime.now() b = datetime.datetime.now()

How to calculate milliseconds,from the code below.

a = datetime.datetime.now()
b = datetime.datetime.now()
c = b - a

&g开发者_如何学JAVAt;>> c

>>> c.days
0
>>> c.seconds
4
>>> c.microseconds


milliseconds = (c.days * 24 * 60 * 60 + c.seconds) * 1000 + c.microseconds / 1000.0


Or, new since 2.7:

c.total_seconds()*1000

(https://docs.python.org/2/library/datetime.html)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号