错误案例
import numpy as np
a = np.array([1, 2, 3], [4, 5, 6])
报错提示
TypeError Traceback (most recent call last)
~AppDataLocalTemp/ipykernel_52444/3433848368.py in <module>
1 import numpy as np
----> 2 a = np.array([1, 2, 3], [4, 5, 6])
TypeError: Field elements must be 2- or 3-tuples, got '4'
正确代码
import numpy as np
# a = np.array([1, 2, 3], [4, 5, 6]) # 错误
a = np.array([[1, 2, 3], [4, 5, 6]]) # 正确