0
arr2=[0]*(x^2) # x is the length of the list data
for i in range(x):
    arr2[i]=data[i].split(',')#data is a list like:['1,2','3,4']
arr2=np.array(arr2)
A=np.asmatrix(arr2)
print A.I

这在设置带有序列的数组元素时会出错

4

1 回答 1

0

像这样的东西:

>>> data = ['1,2','3,4']
>>> arr2=[ map(float,x.split(',')) for x in data]
>>> arr2 = np.asarray(arr2)
>>> A = np.asmatrix(arr2)
>>> A.I
matrix([[-2. ,  1. ],
        [ 1.5, -0.5]])
于 2013-07-03T13:52:28.960 回答