发布时间:2019-08-28 09:24:24编辑:auto阅读(2337)
matrix0 = [[1, 2], [3, 3], [2, 1]]
print 'matrix0:', matrix0
matrix1 = [[1 for i in range(2)] for i in range(3)]
print 'matrix1:', matrix1
matrix2 = [[0 for i in range(2)] for i in range(3)]
print 'matrix2:', matrix2
for i in range(3):
for j in range(2):
matrix2[i][j] = matrix0[i][j] + matrix1[i][j]
print 'matrix2:', matrix2
print('Good bye')
运行结果:
matrix0: [[1, 2], [3, 3], [2, 1]]
matrix1: [[1, 1], [1, 1], [1, 1]]
matrix2: [[0, 0], [0, 0], [0, 0]]
matrix2: [[2, 3], [4, 4], [3, 2]]
Good bye
上一篇: python写的具有CRC16生成、校验
下一篇: 八个最佳Python IDE
47880
46447
37333
34773
29346
26008
24960
19978
19580
18074
5821°
6449°
5962°
5988°
7093°
5937°
5980°
6472°
6435°
7818°