如果一个是25使用python如何得到30

zjm*_*126 0 python math

这是我的代码:

from math import ceil
a = 25
a = float(a/10)
a = int(ceil(a))*10
print a
Run Code Online (Sandbox Code Playgroud)

我得到20,但我想要30,

接下来是我想要的:

if the a is 22 , i want get 20
if the a is 25 , i want get 30
if the a is 27 , i want get 30
if the a is 21 , i want get 20
Run Code Online (Sandbox Code Playgroud)

那我该怎么办

谢谢

SLa*_*aks 7

你正在寻找这个round()功能:

print int(round(25, -1))
Run Code Online (Sandbox Code Playgroud)