首页 > 代码库 > Python List
Python List
1. Basic
list1 = [‘math‘, 1, 2.3]
2. Accessing
list1 = [‘math‘, 1, 2.3] list1[0] list1[1:2]
3. delete
list1 = [‘math‘, 1, 2.3] del list1[0] #‘math‘ will be deleted
4. Built-in function
cmp(list1, list2) #Compares elements of both lists. len(list) #Gives the total length of the list. max(list) #Returns item from the list with max value. min(list) list(seq) #Converts a tuple into list. list.append(obj) #Appends object obj to list list.count(obj) #Returns count of how many times obj occurs in list list.extend(seq) #Appends the contents of seq to list list.index(obj) #Returns the lowest index in list that obj appears list.insert(index, obj) #Inserts object obj into list at offset index list.pop(obj=list[-1]) #Removes and returns last object or obj from list list.remove(obj) #Removes object obj from list list.reverse() #Reverses objects of list in place list.sort([func]) #Sorts objects of list, use compare func if given
Python List
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。