>>> la [1, 2, 3] >>> lb ['qiwsir', 'python'] >>> la.extend(lb) >>> la [1, 2, 3, 'qiwsir', 'python'] >>> lb ['qiwsir', 'python']
>>> la = [1,2,3] >>> b = "abc" >>> la.extend(b) >>> la [1, 2, 3, 'a', 'b', 'c'] >>> c = 5 >>> la.extend(c) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'int' object is not iterable
>>> la [1, 2, 3, 'a', 'b', 'c'] >>> lb ['qiwsir', 'python'] >>> la[len(la):]=lb >>> la [1, 2, 3, 'a', 'b', 'c', 'qiwsir', 'python']
>>> name = 'qiwsir' >>> type(name) <type 'str'> >>> len(name) 6 >>> lname = ['sir','qi'] >>> type(lname) <type 'list'> >>> len(lname) 2 >>> length = len(lname) >>> length 2 >>> type(length) <type 'int'>
>>> la = [1,2,1,1,3]
>>> la.count(1)
3
>>> la.append('a')
>>> la.append('a')
>>> la
[1, 2, 1, 1, 3, 'a', 'a']
>>> la.count('a')
2
>>> la.count(2)
1
>>> la.count(5) #NOTE:la中没有5,但是如果用这种方法找,不报错,返回的是数字0
0
>>> la [1, 2, 3, 'a', 'b', 'c', 'qiwsir', 'python'] >>> la[2] 3 >>> la[2:5] [3, 'a', 'b'] >>> la[:7] [1, 2, 3, 'a', 'b', 'c', 'qiwsir']
>>> la
[1, 2, 3, 'a', 'b', 'c', 'qiwsir', 'python']
>>> la.index(3)
2
>>> la.index('a')
3
>>> la.index(1)
0
>>> la.index('qi') #如果不存在,就报错
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: 'qi' is not in list
>>> la.index('qiwsir')
6
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有