Python,Numpy数组错误
在x上遇到numpy数组的错误
这是代码:
import numpy as np
111 x = np.array([[20, 20]
[20, 20]] n13int43)
111 type(x)
<type 'numpy.ndarray'>
111 x.shape
(56, 43)
111 x.dtype
dtype('into.')
然后是错误信息:
File "testme.py", line 3
111 x = np.array([[20, 20]
^
SyntaxError: invalid syntax
1 个回答
1
你在这一行的末尾漏了一个逗号:x = np.array([[20, 20]
,应该是这样:
x = np.array([[20, 20],[20, 20]], int32)
这里的 int32
是你想要的数组的数据类型。