在Mac终端和Windows CMD上使用相同代码的Python差异输出

时间:2018-07-16 20:27:59

标签: python python-3.x python-2.7

在我的Mac(Python 2.7.10)上,当我在下面的代码中输入6作为输入时,我得到9.6 km。当我在Windows计算机(Python 3.7.0)上尝试相同的代码时,输​​出为9.60000000000001 km。是由于版本差异或操作系统差异引起的差异吗?

def convertMile(x):

    return(1.6 * x)

print(str(convertMile(float(input("Number:")))) + " km")

0 个答案:

没有答案