python list extend()

li = [1, 2]
li2 = [3, 4, 5]
li.append(li2)
print(li)
del li[2]
li.extend(li2)
print(li)
结果:
[1, 2, [3, 4, 5]]
[1, 2, 3, 4, 5]

Process finished with exit code 0

猜你喜欢

转载自blog.csdn.net/qq_41228218/article/details/88939261
今日推荐