Python格式化输出

使用 f-string

print(f"y1/y2: {y1:.6e}/{y2:.6e}")
# y1/y2: 4.282000e-11/1.562123e-10

使用%

print('%d %s cost $%.2f' % (6, 'bananas', 1.74))
# 6 bananas cost $1.74
原文地址:https://www.cnblogs.com/yaos/p/14049789.html