from scipy.sparse import * row = [0,0,0,1,1,1,2,2,2]#行指标col = [0,1,2,0,1,2,0,1,2]#列指标data = [1,0,1,0,1,1,1,1,0]#在行指标列指标下的数字team = csr_matrix((data,(row,col)),shape=(3,3))print(team)print(team.todense()) 输出结果: (0, 0) 1 (0, 1) 0 (0, 2) 1 (1, 0) 0 (1, 1…