Python中自带的extend()
与append()
方法的功能类似但在处理多个列表时,这两种方法的处理结果是完全不同的
>>>a=[1 , 2 , 3]
>>>b=[4 , 5 , 6]
>>>a.append(b)
>>>a
[1 , 2 , 3 , [4 , 5 , 6]]
>>>a.extend(b)
>>>a
[1 , 2 , 3 , 4 ,5 ,6]
Python中自带的extend()
与append()
方法的功能类似但在处理多个列表时,这两种方法的处理结果是完全不同的
>>>a=[1 , 2 , 3]
>>>b=[4 , 5 , 6]
>>>a.append(b)
>>>a
[1 , 2 , 3 , [4 , 5 , 6]]
>>>a.extend(b)
>>>a
[1 , 2 , 3 , 4 ,5 ,6]