# 保留两位小数 temp = 20.30 print('这是format的方式:{:.2f}'.format(temp)) print('这是的%%方式:%.2f' % temp) print('不建议使用round函数:{}'.format(round(temp, 2)))
这是format的方式:20.30 这是的%方式:20.30 不建议使用round函数:20.3