python list: append vs += [duplicate]
问题 This question already has answers here : What is the difference between Python's list methods append and extend? (20 answers) Why does += behave unexpectedly on lists? (9 answers) Closed 2 years ago . For Python list, is append() the same as += ? I know that + will lead to the creation of a new list, while append() just append new stuff to the old list. But will += be optimized to be more similar to append() ? since they do the same thing. 回答1: It's an __iadd__ operator. Docs. Importantly,