参考https://www.cnblogs.com/walo/p/10608436.html字符串前加 f import timet0 = time.time()time.sleep(1)name = 'processing'# 以 f开头表示在字符串内支持大括号内的python 表达式print(f'{name} done in {time.time() - t0:.2f} s') 输出:processing done in 1.00 s