正确代码 def sumNumber(integer_num): print(" i || m(i)") print("-"*30) a = 0 for i in range(1, integer_num + 1): a += i / (i + 1) print("{:4d} || {:.4f}".format(i, a)) sumNumber(20) 结果如下