从来就做下面的代码:
import numpy as np
import cmath as cmh
import pylab as pl
import matplotlib.pyplot as plt
import time
import sympy as sp
x = sp.Symbol('x')
def function2(a,b,x):
G=np.zeros([1,1],dtype=np.ndenumerate)
G[0,0]=a*x+b
return G
K=function2(1,2,x)
g=K.evalf(subs={x:3})
print(g)
但是荫获取以下错误
File "C:\WinPython-64bit-3.5.1.3\python-3.5.1.amd64\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 841, in runfile
execfile(filename, namespace)
File "C:\WinPython-64bit-3.5.1.3\python-3.5.1.amd64\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 103, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/MS/Desktop/symbol.py", line 40, in <module>
g=K.evalf(subs={x:3})
**AttributeError: 'numpy.ndarray' object has no attribute 'evalf'**
我是否必须以某种方式修改数组?