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
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
本文标题:python两个列表实例如何相加或相减
本文链接:https://www.haomeiwen.com/subject/encatktx.html
网友评论