round函数怎么使用的
使用方法如下: 1. round(x):对x进行四舍五入,默认保留到整数。 2. round(x, n):对x进行四舍五入,保留n位小数。n可以为负数,表示保留到整数位。 例如: ```python x = 3.1415926 print(round(x)) # 输出:3 y = 3.1415926 print(round(y, 2)) # 输出:3.14 z = 3.1415926 print(round(z, -1)) # 输出:0 ``` 在这些例子中,`round(x)`将3...