python time(milli seconds) calculation

后端 未结 2 761
别跟我提以往
别跟我提以往 2020-12-11 16:22

How to calculate milliseconds,from the code below.

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

>>> c

>>> c.days
0
&         


        
相关标签:
2条回答
  • 2020-12-11 16:36
    milliseconds = (c.days * 24 * 60 * 60 + c.seconds) * 1000 + c.microseconds / 1000.0
    
    0 讨论(0)
  • 2020-12-11 17:00

    Or, new since 2.7:

    c.total_seconds()*1000
    

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

    0 讨论(0)
提交回复
热议问题