Python.append()与Python.expand()用法详解
作者:sdd220 时间:2022-01-22 20:51:42
如下所示:
alist=[1,2]] >>>[1,2]
alist.append([3,4]) >>>[1, 2, [3, 4]]
alist.extend([3,4]) >>>[1, 2, 3, 4]
结论:
list.apend(arg1) 参数类型任意,可以往已有列表中添加元素,若添加的是列表,就该列表被当成一个元素存在原列表中,只使list长度增加1.
list.extend(list1) 参数必须是列表类型,可以将参数中的列表合并到原列表的末尾,使原来的 list长度增加len(list1)。
来源:https://blog.csdn.net/sdd220/article/details/78315648
标签:Python,append,expand
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
15款非常有用的前端开发CSS网格(grid system)生成器
2009-07-06 13:02:00
![](https://img.aspxhome.com/file/UploadPic/20097/6/grid-layout-generator-by-pagecolumn-14s.jpg)
Python中安装easy_install的方法
2022-06-22 20:30:00
![](https://img.aspxhome.com/file/2023/5/89165_0s.png)
IE中选择符的4095限制
2009-10-09 13:25:00
使用 Python 遍历目录树的方法
2021-09-21 22:19:32
python实现WebSocket服务端过程解析
2022-09-14 10:45:19
![](https://img.aspxhome.com/file/2023/5/75855_0s.png)
修改SQL Server 2005 sa用户密码的方法
2008-12-10 14:41:00
Oracle轻松取得建表和索引的DDL语句
2009-02-26 10:26:00
SQL离前端有多远?
2009-05-21 10:37:00
简单实用的图片播放器1.0(Javascript + css )
2008-07-16 10:39:00
![](https://img.aspxhome.com/file/UploadPic/20087/16/meinv_67s.gif)
详解Python字符串切片
2021-09-10 05:10:43
![](https://img.aspxhome.com/file/2023/5/67425_0s.png)
Python cookbook(数据结构与算法)从序列中移除重复项且保持元素间顺序不变的方法
2023-03-01 14:24:38
python Pexpect模块的使用
2023-01-23 20:54:58
服务端XMLHTTP(ServerXMLHTTP in ASP)进阶应用-User Agent伪装
2008-11-11 12:29:00
![](https://img.aspxhome.com/file/UploadPic/200811/11/if8l_googlerss-96s.png)
9个Web设计中常见的可用性错误[译]
2009-03-11 20:25:00
![](https://img.aspxhome.com/file/UploadPic/20093/11/01-10s.jpg)
Python中的多线程实例(简单易懂)
2021-12-07 04:09:47
![](https://img.aspxhome.com/file/2023/7/80447_0s.png)
Go语言使用sort包对任意类型元素的集合进行排序的方法
2023-09-02 03:55:18
DW中如何使用Library
2007-02-03 11:39:00
加固SQL参数与存储过程
2012-03-12 19:44:08
精细讲述SQL Server数据库备份多种方法
2009-01-13 13:33:00
python爬虫beautiful soup的使用方式
2023-05-17 08:13:22
![](https://img.aspxhome.com/file/2023/7/72267_0s.png)