简体   繁体   中英

convert microseconds into a human readable time

I need to convert a time difference (diff) between two actions into a human readable time.

How can I do this with python? I tried something like

    diff = 49503757
    datetime.time(0,0,0,diff)

but the diff value was too long, the datetime expects a value of microseconds in between 0 and 999999 and my diff in this example was 49503757.

>>> from datetime import timedelta
>>> str(timedelta(microseconds=49503757))
'0:00:49.503757'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM