python两个列表实例如何相加或相减
2020-06-13 本文已影响0人
隔壁小红馆
import numpy as np
a = [10, 20, 30, 40]
b = [50, 60, 70, 80]
a_np = np.array(a)
b_np = np.array(b)
c_add= a_np + b_np
d_subtract = a_np - b_np
print(c_add) # [ 60 80 100 120]
print(d_subtract) # [-40 -40 -40 -40]
计算.png
结果.png