python如何将列表添加到另一列表

时间:2024-10-13 08:37:57

1、打开一个python文件。

python如何将列表添加到另一列表

2、然后定义一个列表,名为furniture1。

python如何将列表添加到另一列表

3、然后定义第二个列表,名为furniture2。

python如何将列表添加到另一列表

4、如果我们想要将furniture2这个谱驸扌溺列表添加到furnirure1这个列表中,使用extend方法就可以实现,可以这样写:furniture1.extend(furniture2)

python如何将列表添加到另一列表

5、用print函数将furniture1这个列表打印出来。

python如何将列表添加到另一列表

6、右键单击,弹出菜单,点击run code运行程序命令。

python如何将列表添加到另一列表

7、在输出控制台就可以看到结果了,furniture2列表的内容添加到了furniture1这个列表中去了。

python如何将列表添加到另一列表
© 手抄报圈