#借用線性代數(shù)的說(shuō)法, 一維數(shù)組通常稱為矢量 (vector),二維數(shù)組通常稱為矩陣(matrix)。
matrix = np.array([1,'Tim'],[2,'Joey'],[3,'Johnny'])
print(matrix)
TypeErrorTraceback (most recent call last)CellIn[10], line 1----> 1matrix=np.array([1,'Tim'],[2,'Joey'],[3,'Johnny']) 2print(matrix)TypeError: array() takes from 1 to 2 positional arguments but 3 were given
解決方法:
matrix = np.array([[1,'Tim'],[2,'Joey'],[3,'Johnny']])
print(matrix)