2024-04-19 23:13:21 发布
网友
这是我的密码:
from math import ceil a = 25 a = float(a/10) a = int(ceil(a))*10 print a
我得到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
那我该怎么办
谢谢
您可以使用round() method
>>> num = 25 >>> round_num = int(round(num, -1)) >>> round_num 30 >>> num = 22 >>> round_num = int(round(num, -1)) >>> round_num 20
等等。你知道吗
您正在寻找^{} function:
print int(round(25, -1))
您可以使用round() method
等等。你知道吗
您正在寻找^{} function :
相关问题 更多 >
编程相关推荐