Oleg Chaika Asked:2020-09-22 14:45:04 +0000 UTC2020-09-22 14:45:04 +0000 UTC 2020-09-22 14:45:04 +0000 UTC 四舍五入python 772 输出文件应包含一个四舍五入到小数点后 n 位的实数。怎么做? python 1 个回答 Voted Best Answer Serhii 2020-09-22T15:46:47Z2020-09-22T15:46:47Z round(number[, ndigits])- 将数字四舍五入到 ndigits 小数位(默认情况下,为零位,即最接近的整数) In [37]: n = 33/7 In [38]: n Out[38]: 4.714285714285714 In [39]: round(n, 1) Out[39]: 4.7 In [40]: round(n, 4) Out[40]: 4.7143 链接到英文文档
round(number[, ndigits])- 将数字四舍五入到 ndigits 小数位(默认情况下,为零位,即最接近的整数)链接到英文文档