慕神8447489
在不同的Python版本中,round函数的取值会出现不同状况在Python2.7中,round函数的定义是如果输入数值距离两边一样远,则取偶数的一边~python2Python2.7.13(v2.7.13:a06454b1afa1,Dec172016,12:39:47)[GCC4.2.1(AppleInc.build5666)(dot3)]ondarwinType"help","copyright","credits"or"license"formoreinformation.>>>round(0.5)1.0在Python3中,round函数的定义是四舍五入。Python3.6.0(v3.6.0:41df79263a11,Dec222016,17:23:13)[GCC4.2.1(AppleInc.build5666)(dot3)]ondarwinType"help","copyright","credits"or"license"formoreinformation.>>>round(0.5)0楼上那位是用了ipython,是基于python2的,所以定义也遵从Python2的。