方法1中所有行中索引1的值都会更改。如何正确创建ar1数组?
方法1:
Team
方法2:
UserTeam
输出1:
ToDTO()
输出2:
ar1= [[0] * 3] * 3
ar1[0][1]=5
print(ar1)
答案 0 :(得分:0)
arr1 = [[0,0,0],[0,0,0],[0,0,0]]
(或)
arr1 = [[0]*3 for _ in range(3)]
(或)
arr1 = [[0 for _ in range(3)] for _ in range(3)]