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

前端 未结 8 1924
渐次进展
渐次进展 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 22:02

    You are looking at the wrong documentation. The time module has different documentation.

    You can use the datetime module strftime like this:

    >>> from datetime import datetime
    >>>
    >>> now = datetime.now()
    >>> now.strftime("%H:%M:%S.%f")
    '12:19:40.948000'
    

提交回复
热议问题