1 个回答|384 次阅读
一、使用Python内置方法zip()
x = [1, 2, 3, 4]
y = [4, 5, 6, 7]
z = []
for i, j in zip(x, y):
z.append(i + j)
print(z)
执行结果:
[5,7,9,11]
二、使用numpy的通用函数add()
import numpy as np
x = [1, 2, 3, 4]
y = [4, 5, 6, 7]
z = np.add(x, y)
print(z)
执行结果:
[5 7 9 11]
请先 登录 后评论