Python 官方文档:入门教程 => 点击学习
python中使用round函数取小数,具体方法如下:round:round()函数的作用是回浮点数x的四舍五入值。round()函数语法:round( x [, n] )参数:x :数值表达式。n :数值表达式,表示从小数点位数。roun
python中使用round函数取小数,具体方法如下:
round:round()函数的作用是回浮点数x的四舍五入值。
round()函数语法:
round( x [, n] )
参数:
x :数值表达式。
n :数值表达式,表示从小数点位数。
round()函数使用方法:
print "round(80.23456, 2) : ", round(80.23456, 2)
print "round(100.000056, 3) : ", round(100.000056, 3)
print "round(-100.000056, 3) : ", round(-100.000056, 3)
输出结果为:
round(80.23456, 2) : 80.23
round(100.000056, 3) : 100.0
round(-100.000056, 3) : -100.0
--结束END--
本文标题: Python中取小数用什么函数
本文链接: https://www.lsjlt.com/news/114795.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