The Python shell repeats the last command: alt+p
2.3 List: Python's drudgery
(1) List function
(2) Assign a value to a list without jumping to a location where an element does not exist.
(3) Delete element, Del name[1]
(4) Shard assignment, name[2:]=list (' ar ')
List methods: Objects. Methods (Parameters)
(1) A.append (6) Add a new object at the end of the list
(2) Number of A.count ("DH") statistics elements appearing in the list
(3) a.extend (b) Multiple values can be appended at the end of the list at once
(4) A.index find the index value of the first occurrence of a value from the list
(5) Insert A.insert (3, ' four ') inserts the string four into the front of the index value 3
(6) A.pop () Delete the element I, the default is to delete the last one, the element that is deleted is returned
(7) A.remove ("Sih") removes the first matching value of a value in the list, no return value
(8) A.reserve () reverse the elements in the array
(9) A.sort () sort the list in the original location
(ten) sorted (a) will return a sequenced queue
There is also an advanced sort of generic template programming similar to C + +
Numbers.sort (CMP) is sorted according to a comparison function CMP, CMP (x, y) x>y 1, x<y -1,x=y 0
X.sort (reverse=true) here indicates whether to reverse sort
X.sort (Key=len) here means that the keyword is len, which is sorted by the length of each element
2.4 Tuples: Immutable sequences, and string literals are immutable.
(a) A general form of a tuple
Truple ([+]) convert a list to a tuple
Tuples can be used as keys in mappings and members of collections, but not in lists.
Python Basic Tutorial Notes-Chapter 2nd: Lists and tuples