Python 官方文档:入门教程 => 点击学习
在python中使用round()函数保留小数点任意位数的方法round:round()函数的作用是用于返回浮点数 x 的四舍五入值。round()函数语法:round( x [, n] )参数:x:数字表达式。n:表示需保留的小数点位数,
在python中使用round()函数保留小数点任意位数的方法
round:round()函数的作用是用于返回浮点数 x 的四舍五入值。
round()函数语法:
round( x [, n] )
参数:
x:数字表达式。
n:表示需保留的小数点位数,默认值为 0。
round()函数使用方法:
print ("round(70.23456) : ", round(70.23456))
print ("round(56.659,1) : ", round(56.659,1))
print ("round(80.264, 2) : ", round(80.264, 2))
输出结果为:
round(70.23456) : 70
round(56.659,1) : 56.7
round(80.264, 2) : 80.26
--结束END--
本文标题: python中使用round函数保留小数点任意位数
本文链接: https://www.lsjlt.com/news/112751.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0