List lists
Methods available in the list class (total 11 types)
1. The original value was last appended
Li.append ()
2. Clear the list
Li.clear ()
3. Copy, Shallow copy
Li.copy ()
4. Count the number of occurrences of an element
Li.count (value)
5. Expand the original list, parameters: can iterate objects
Li.extend (objects that can be iterated)
6. Get the current value index position by value (left priority)
Li.index (value)
7. Inserting an element at the specified index location
Li.insert (index position, value)
8. Delete a value (1. Specify an index; 2. The last one by default) and get the deleted value
Li.pop ( index )
9. Delete the specified value from the list, the left priority
Li.remove (value)
3 Del[1]
4 Del[2:3]
5 Clear
10 Flipping the current list
Li.reverse ()
11 Sorting of Lists
Li.sort () #从小到大
Li.sort (reverse=true) #从大到小
List Description:
1. List format
2, the list can be nested any type
3, the list can be indexed value
4, the list can be sliced to value, the result is also a list
5. The list can be for loop, while loop
6, the list can be indexed modification, slice modification
7. The list can be used to determine whether the element is in the list
8, list can be used li[3][1][2][1] way to find in depth
9, list conversion, string conversion to a list by default for loop; A list conversion to a string requires you to write a for-loop one-by-one processing; if all of the lists are strings, you can convert them in join mode
*************************************************************************************************
Tuple tuples
Methods provided in the tuple class: (2 total)
1. Gets the number of occurrences of the specified element in the tuple
Tu.count (Element)
2. Gets the position of the specified element in the tuple (left priority)
Tu.index (Element)
Tuple Description:
1, writing format, generally write the tuple when, recommended in the last to join,
2. Can be indexed
3, can be sliced
4. Can be used for loop
5. Can be converted to list, string
6, the first level element of the tuple cannot be modified/deleted/Added
Pycharm tips:
Click Code,reformatcode to help organize the formatting and handle the underline
The third day PYTHON basic data Type-list-tuples