在datetime模块,使用格式化符号 '%f'。
import datetime
time_now = datetime.datetime.now().strftime('%H:%M:%S.%f')
print(time_now)
%H Hour (24-hour clock) as a decimal number [00,23].
%M Minute as a decimal number [00,59].
%S Second as a decimal number [00,61].
%f Microsecond as a decimal number [0,999999], zero-padded on the left.