下面的小程序在使用Python 3.8时会失败,但在2.7下是可以的:
from mpmath import mpf, nsum
def z(n):
x = [mpf(1) for k in range(1,n)]
return 99
print (nsum(z, [2,2]))代码看起来很奇怪,因为它是从一个相当大的程序中裁减出来的。我不能再减价了。使用https://www.python.org/shell/上的交互式外壳可以很容易地确认这一点
错误报告为:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/site-packages/mpmath/calculus/extrapolation.py", line 1698, in nsum
return +g()
File "/usr/lib/python3.8/site-packages/mpmath/calculus/extrapolation.py", line 1745, in <lambda>
return False, lambda: f(*([0]*len(intervals)))
File "/usr/lib/python3.8/site-packages/mpmath/calculus/extrapolation.py", line 1777, in g
s += f(*args)
File "<stdin>", line 2, in z
TypeError: 'mpf' object cannot be interpreted as an integer我是不是漏掉了什么明显的东西?
https://stackoverflow.com/questions/59477997
复制相似问题