测试代码:
#test code
import numpy as np
a = np.zeros(2, dtype=np.int32)
print(a)
b = np.zeros((4, 4), dtype=np.int32)
print(b)
b[a[0], a[1]] = 1
print(b)
输出:
[0 0]
[[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]]
[[1 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]]