1个回答
展开全部
那说明你用的是python2, python3会是5.0 和 5
round函数:
Docstring:round(number[, ndigits]) -> number
Round a number to a given precision in decimal digits (default 0 digits).
This returns an int when called with one argument, otherwise the
same type as the number. ndigits may be negative.Type: builtin_function_or_method
可以看到其接受两个参数,其中第二个参数是位数, 默认为0
所以区别是round(23/5, 0) 和round(23/5.0, 0)
python2中23/5 = 4
python3中23/5 = 4.6
round函数:
Docstring:round(number[, ndigits]) -> number
Round a number to a given precision in decimal digits (default 0 digits).
This returns an int when called with one argument, otherwise the
same type as the number. ndigits may be negative.Type: builtin_function_or_method
可以看到其接受两个参数,其中第二个参数是位数, 默认为0
所以区别是round(23/5, 0) 和round(23/5.0, 0)
python2中23/5 = 4
python3中23/5 = 4.6
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询