import numpy as np r = 2 c = 2 #在默认的情况下,zeros创建的数组元素类型是浮点型的,如果要使用其他类型,可以设置dtype参数进行声明。 X = np.zeros((3,3)) #X = np.zeros((3,3),dtype=int) X[0, 1:] = 77 X[1:, 0] = 99 print(X) for i in range(r): #print("i=" + str(i)) for j in range(c): #print("j=" + str(j)) X[i, j] = 1 #X[i + 1, j + 1] = 1 print(X)