擅长:python、mysql、java
<p>如果您的数据非常大,您可能需要查看numpy模块。如果没有,您可以使用zip和列表:</p>
<pre><code>matrix = [[ -9.022, -81.936, -1.822],
[ -9.554, -82.001, -1.929],
[-10.186, -81.872, -1.779],
[-16.673, 76.043, -18.319],
[-16.989, 76.213, -17.823],
[-17.568, 75.554, -18.709]]
cras = [-3.433, 18.419, 28.598]
result = [ [ a+b for a,b in zip(cras,line) ] for line in matrix ]
for line in result: print(line)
# (rounded and aligned the printed values for legibility)
[-12.455, -63.517, 26.776]
[-12.987, -63.582, 26.669]
[-13.619, -63.453, 26.819]
[-20.106, 94.462, 10.279]
[-20.422, 94.632, 10.775]
[-21.001, 93.973, 9.889]
</code></pre>