输入一个小数,输出四舍五入的结果

注意:不能直接使用round()进行处理,具体请百度round()用法

方法1:

a =float(input())  #input()是string类型,需要强转

print(int(a)+1 if a-int(a)>=0.5 else int(a)) #int(小数)=小数的整数部分

方法2:

进阶round()方法 --待后续补充

原文地址:https://www.cnblogs.com/jesse-zhao/p/14494201.html