Using %f with strftime() in Python to get microseconds

前端 未结 8 1922
渐次进展
渐次进展 2020-11-29 21:32

I\'m trying to use strftime() to microsecond precision, which seems possible using %f (as stated here). However when I try the following code:

import time
im         


        
8条回答
  •  失恋的感觉
    2020-11-29 21:52

    This should do the work

    import datetime
    datetime.datetime.now().strftime("%H:%M:%S.%f")
    

    It will print

    HH:MM:SS.microseconds like this e.g 14:38:19.425961

提交回复
热议问题