python 中的list.append()和list.extend()区别

实例:

>>list_append = [1,2,3]
>>list_extend = [4,5,6]
>>list_append.append(list_extend)
>>[1,2,3,4,5,6]
>>list_extend.extend(list_append)
>>[1,2,3,[4,5,6]]

list.append(obj)把obj做为对象加入到list中

list.extend(seq)把seq做为序列加入到list中



猜你喜欢

转载自blog.csdn.net/lerry13579/article/details/80255568
今日推荐