如何通过a b得到c
本文以“乘”引入,其他运算,类似。案例逻辑如下:
a = [[1, 2, 3], [4, 5, 6], [1, 1, 1]]
b = [[1, 1, 2], [1, 3, 2], [2, 1, 1]]
c = [[1, 2, 6], [4, 15, 12], [2, 1, 1]]
#代码
c = [[1, 1, 2], [1, 3, 2], [2, 1, 1]]
for i in range(len(a)):
for j in range(len(a[i])):
c[i][j] = a[i][j]*b[i][j]
c
欢迎大家指点更优秀的代码