[python3 - Basic] List
2021-06-27 14:04
标签:xtend att string this erro 添加 list ext class Attribute 1. len() Condition 1. 如果元素存在list中 2. 如果list不为空 Add 1. append() - 在尾部加element 2. extend([]) - 在list后面,添加多个element Delete 1. del 2. pop() Get 1. index(value) - 查找list中的值,并返回其下标 [python3 - Basic] List 标签:xtend att string this erro 添加 list ext class 原文地址:https://www.cnblogs.com/break-dawnn/p/8983580.htmllist = [1,2,3]
length = len(list)
list = [‘a‘, ‘b‘, ‘c‘]
str = ‘a‘
if str in list:
print("This string is in the list.")list = []
if not list:
print ("List is empty.")
list = [1,2,3]
list.append(4) # list=[1,2,3,4]
list1 = [‘a‘,‘b‘,‘c‘]
list2 = list1.extend([‘d‘,‘e‘]) #list2 = [‘a‘,‘b‘,‘c‘,‘d‘,‘e‘]
list = [1,2,3]
del list[-1] #list = [1,2]
list = [1,2,3]
lastEle = list.pop() # lastEle = 3
list = [1,2,6]
idx = list.index(1) #0
idx = list.index(3) #ValueError: 3 is not in list
文章标题:[python3 - Basic] List
文章链接:http://soscw.com/index.php/essay/98447.html