python中append、extend、和insert的区别
a_list = [x for x in range(1, 11)]
print(a_list)
a_list.append('sdadfewf') # 将整个字符串放到列表的最后
print(a_list)
# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'sdadfewf'] b_list = [x for x in range(1, 11)]
print(b_list)
b_list.extend('sdadfewf') # 将字符串中的每个元素放到列表的最后
print(b_list)
# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 's', 'd', 'a', 'd', 'f', 'e', 'w', 'f'] c_list = [x for x in range(1, 11)]
print(c_list)
c_list.insert(3, 'sdadfewf') # 将整个字符串插入到列表索引为3的位置
print(c_list)
# [1, 2, 3, 'sdadfewf', 4, 5, 6, 7, 8, 9, 10]
python中append、extend、和insert的区别的更多相关文章
- python中import和from...import...的区别
python中import和from...import...的区别: 只用import时,如import xx,引入的xx是模块名,而不是模块内具体的类.函数.变量等成员,使用该模块的成员时需写成xx ...
- 转发 python中file和open有什么区别
python中file和open有什么区别?2008-04-15 11:30地痞小流氓 | 分类:python | 浏览3426次python中file和open有什么区别?都是打开文件,说的越详细越 ...
- Python中str()与repr()函数的区别——repr() 的输出追求明确性,除了对象内容,还需要展示出对象的数据类型信息,适合开发和调试阶段使用
Python中str()与repr()函数的区别 from:https://www.jianshu.com/p/2a41315ca47e 在 Python 中要将某一类型的变量或者常量转换为字符串对象 ...
- python中List append()、extend()和insert()的区别
Python中向列表增加更多数据时,有append().extend()和insert()等方法 其中最常用的是list.append(obj) 向列表的尾部添加一个新的元素. 需要一次性添加多个元素 ...
- Python中 append 和 extend 的区别
Python中Lists 的两个方法: append 和 extend : list.append(object) 向列表中添加一个对象object.append 接受一个参数,这个参数可以是任何数据 ...
- python中list/tuple/dict/set的区别
序列是Python中最基本的数据结构.序列中的每个元素都分配一个数字 - 它的位置,或索引,第一个索引是0,第二个索引是1,依此类推.Python有6个序列的内置类型,但最常见的是列表list和元组t ...
- Python中list,tuple,dict,set的区别和用法
Python语言简洁明了,可以用较少的代码实现同样的功能.这其中Python的四个内置数据类型功不可没,他们即是list, tuple, dict, set.这里对他们进行一个简明的总结. List ...
- Python中list,tuple,dict,set的区别和用法(转)
原文地址:http://www.cnblogs.com/soaringEveryday/p/5044007.html Python语言简洁明了,可以用较少的代码实现同样的功能.这其中Python的四个 ...
- Python中str()与repr()函数的区别
在 Python 中要将某一类型的变量或者常量转换为字符串对象通常有两种方法,即str()或者 repr() . >>> a = 10 >>> type(str(a ...
- python中的__init__和__new__的区别
一.__init__ 方法是什么?(init前后的线是双下划线) 使用Python写过面向对象的代码的同学,可能对 __init__ 方法已经非常熟悉了,__init__ 方法通常用在初始化一个类实例 ...
随机推荐
- ZR#997
ZR#997 解法: 找找规律就出来了,全场最简单的一道题. CODE: #include<iostream> #include<cstdio> #include<cst ...
- Tecplot如何提取三维图中某条线的数据【转载】
转载自:http://blog.sina.com.cn/s/blog_9de422500102v9by.html 截取线所在的面Data.Extract .slice from Plane,显示如下窗 ...
- 8. String to Integer (atoi) ---Leetcode
Implement atoi to convert a string to an integer. 题目分析: 题目本身很简单就是将一个字符串转化成一个整数,但是由于字符串的千差万别,导致在实现的时候 ...
- 5分钟学会如何创建spring boot项目
上一篇博客说了如何创建spring boot项目,但是有些同学会觉得有点麻烦,有没有什么快速学会能快速创建spring boot项目的方法,答案是肯定的.接下来我们就一起来快速创建一个spring b ...
- 2018-2019-2 20165234 《网络对抗技术》 Exp9 Web安全基础
Exp9 Web安全基础 一. 实践内容 1. 安装JDK.Webgoat 2. SQL注入攻击 数字型注入(Numeric SQL Injection) 日志欺骗(Log Spoofing) 字符串 ...
- Linux perl: warning: Setting locale failed.perl: warning: Please check that your locale settings:
使用 apt-get 安装软件时,总是出现下面的错误. perl: warning: Setting locale failed. perl: warning: Please check that y ...
- maven报错解决
maven-resources-plugin prior to 2.4 is not supported by m2e. Use maven- resources-plugin versio < ...
- gevent学习
gevent gevent基于协程的网络库,基于libev的快速的事件循环,基于greenlet的轻量级执行单元,重用了Python标准库中的概念,支持socket.ssl.三方库通过打猴子补丁的形式 ...
- osgViewer::Viewer::Windows
osg自带窗口去掉边框 #ifdef _WIN32 #include <Windows.h> #endif // _WIN32 #include<iostream> #incl ...
- List根据多个字段分组
List<ClassEntity> distinctClass = classEntities.stream().collect(Collectors.collectingAndThen( ...