python 格式化输出保留两位小数
#方法1:print("%.2f" % 0.13333)#方法2print("{:.2}".format(0.13333))#方法3round(0.13333, 2)
文章共70字 · 阅读需要大约1分钟
一键AI生成摘要,助你高效阅读
问答
·
#方法1:
print("%.2f" % 0.13333)
#方法2
print("{:.2}".format(0.13333))
#方法3
round(0.13333, 2)
感谢网友回复,"{:.2}".format是保留两位有效数字。
>>> print("{:.2}".format(1433.13333))
>>> 1.4e+03
更多推荐
已为社区贡献2条内容
所有评论(0)