为什么必须乘以1.0才可以得出精确值
def average(*args): if len(args)>0: return sum(args)*1.0/len(args) else: return 'hello' print (average()) print (average(1, 2)) print (average(1, 2, 2, 3, 4))
def average(*args): if len(args)>0: return sum(args)*1.0/len(args) else: return 'hello' print (average()) print (average(1, 2)) print (average(1, 2, 2, 3, 4))
2018-08-01
举报