列表使用切片
如图:
import numpy as np
a = [[1,2,3,4],
[2,3,4,5],
[3,4,5,6]
]
#a = np.array(a)
print(a[:,1])
将出现错误: TypeError: list indices must be integers or slices, not tuple
将把列表a转为数组后,就可以了
输入结果:[2 3 4]
列表使用切片
如图:
import numpy as np
a = [[1,2,3,4],
[2,3,4,5],
[3,4,5,6]
]
#a = np.array(a)
print(a[:,1])
将出现错误: TypeError: list indices must be integers or slices, not tuple
将把列表a转为数组后,就可以了
输入结果:[2 3 4]