Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
433 views
in Technique[技术] by (71.8m points)

python - 如何在不修改任何一个列表的情况下获取Python中两个列表的串联? [重复](How can I get the concatenation of two lists in Python without modifying either one? [duplicate])

This question already has an answer here:

(这个问题在这里已有答案:)

In Python, the only way I can find to concatenate two lists is list.extend , which modifies the first list.

(在Python中,我可以找到连接两个列表的唯一方法是list.extend ,它修改了第一个列表。)

Is there any concatenation function that returns its result without modifying its arguments?

(是否有任何串联函数返回其结果而不修改其参数?)

  ask by Ryan Thompson translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yes: list1+list2 .

(是: list1+list2 。)

This gives a new list that is the concatenation of list1 and list2 .

(这给出了一个新列表,它是list1list2的串联。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...