python中的extend

extend()拓展列表,批量写入

举个例子:

1 a = ["hello", "world", "dlrb"]
2 b = [1, 2, 3,]
3 a.extend(b)
4 print(a)

输出结果:

['hello', 'world', 'dlrb', 1, 2, 3]

我们通过extend将列表b的元素全部写入到列表a中

posted @ 2017-09-16 10:09  萌萌哒小强儿  阅读(5518)  评论(0编辑  收藏  举报