List python learning diary 2-

[,,,] represents a list

Access list element name [2]

Index starting from 0

name[2].title()

Modify an element name [2] = 'xxxxxx'

name.append ( 'xxx') --- End of list element is added

After name.insert (0, 'xxx') --- inserted list elements [0] position of the shift elements and the rear element

del name [0] --- delete the list [0] position of the element

name.pop () --- delete the end of the list of elements, and eject him

a = name.pop (5) --- delete a list [5] position of the element, and he was assigned to a pop-up

name.remove ( 'shanghai') --- delete elements in the list is 'shanghai' of

ps: if two identical values ​​exist in the list, delete the number from the left of the first value of

name.sort () --- permanent sorting

name.sort (reverse = True) --- permanent reverse sort

sorted (name) --- temporary sort (you can also pass parameters affect the ordering)

name.reverse () inverted list element arranged ---

len (name) --- Back List Length

Guess you like

Origin www.cnblogs.com/tangcupaigu/p/11109242.html