我执行了round(395,-2),它将400作为output.How返回,这件事起作用了。?
发布于 2018-05-28 18:45:58
在您提供的示例中,round(395, -2)的意思是第395圈到最近的100。
函数round将所需的精度作为第二个参数。负精度意味着要在小数点之前删除有意义的数字。
round(123.456, 3) # 123.456
round(123.456, 2) # 123.45
round(123.456, 1) # 123.4
round(123.456, 0) # 123.0
round(123.456, -1) # 120.0
round(123.456, -2) # 100.0
round(123.456, -3) # 0.0https://stackoverflow.com/questions/50572004
复制相似问题