使用 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
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