問題:
I have now:我現在有了:
list1 = [1, 2, 3]
list2 = [4, 5, 6]
I wish to have:我希望有:
[1, 2, 3]
+ + +
[4, 5, 6]
|| || ||
[5, 7, 9]
Simply an element-wise addition of two lists.簡單地將兩個列表按元素相加。
I can surely iterate the two lists, but I don't want do that.我當然可以迭代這兩個列表,但我不想這樣做。
What is the most Pythonic way of doing so?這樣做的最 Pythonic 的方式是什麼?
解決方案:
參考一: https://stackoom.com/question/1GWBl參考二: Element-wise addition of 2 lists?