python列表连接列表
In this tutorial, we will unveil different methods to concatenate lists in Python. Python Lists serve the purpose of storing homogeneous elements and perform manipulations on the same.
在本教程中,我们将揭示在Python中串联列表的不同方法。 Python列表用于存储同类元素并对其进行操作。
In general, Concatenation is the process of joining the elements of a particular data-structure in an end-to-end manner.
通常,串联是指以端到端的方式连接特定数据结构的元素的过程。
The following are the 6 ways to concatenate lists in Python.
以下是在Python中串联列表的6种方法。
- concatenation (+) operator 串联(+)运算符
- Naive Method 天真的方法
- List Comprehension 清单理解
- extend() method extend()方法
- ‘*’ operator '*'运算符
- itertools.chain() method itertools.chain()方法
1.用于列表串联的串联运算符(+) (1. Concatenation operator (+) for List Concatenation)
The '+' operator
can be used to concatenate two lists. It appends one list at the end of the other list and results in a new list as output.
'+' operator
可用于连接两个列表。 它在另一个列表的末尾追加一个列表,并产生一个新列表作为输出。
Example:
例:
list1 = [10,