先将整型转换成float型,在计算,结果就有小数了
>>> a = 10 >>> b = 4 >>> c = a/b >>> a,b,c (10, 4, 2) >>> a = float(a) >>> d = a/b >>> a,b,d (10.0, 4, 2.5) >>>