美文网首页
py3笔记44:内置函数之round

py3笔记44:内置函数之round

作者: _百草_ | 来源:发表于2023-06-04 11:56 被阅读0次
# round(x[,n])
# x 数学表达式,n表示小数点位数,默认值是0
# round 四舍五入,准确来说,若两边一样距离,则会保留到偶数的一遍
print(round(1.5)) # 2
print(round(-0.5)) # 0
print(round(0.5)) # 0
# https://blog.csdn.net/weixin_39593593/article/details/111427272

print(round(70.2345,3)) # 70.234
print(round(2.675,2))  # 2.67  与浮点数的精度有关
# https://m.runoob.com/python3/python3-func-number-round.html

相关文章

网友评论

      本文标题:py3笔记44:内置函数之round

      本文链接:https://www.haomeiwen.com/subject/oscvedtx.html