list中 append 与 extend

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sumup/article/details/85466868
a = [1,2,3]
b = [4,5,6]
# 无返回值,错误写法 ==》a=a.append(b)
a.append(b)
print(a)
# [1, 2, 3, [4, 5, 6]]
a.extend(b)
print(a)
# [1, 2, 3, [4, 5, 6], 4, 5, 6]

猜你喜欢

转载自blog.csdn.net/sumup/article/details/85466868
今日推荐