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
posted @ 2020-11-27 18:55  2021年的顺遂平安君  阅读(128)  评论(0编辑  收藏  举报