Basic data type (2), data type (2)
I. List
# Create a list # Method 1: name_list = [1, 2, 3, "reese", "neo"] print (name_list) # Method 2: v = list ([1, 2, 3, "reese", "neo"]) print (v)
Supported basic operations:
- Index
- Slice
- Modify
- Delete
- Loop
- Include
1. append
2. clear
3. copy
4. count
5. extend
6. index
7. insert
8. pop
9. remove
10. reverse
11. sort
Ii. yuanzu
# Create a ancestor #1: v = (1, 2, 3, 4) #2: v = tuple (1, 2, 4 ))
Basic operations:
- Index
- Slice
- Loop, iteratable object
- Conversion
- Primary elements of tuples cannot be deleted or modified.
3. Dictionary
Create a dictionary:
#1:v = {"name": "reese", "age": "18"}#2:v = dict({"name": "reese", "age": "18"})
Common Operations:
- Key-value pairs. The value in the dictionary can be any value.
- Boolean values, lists, and dictionaries cannot be keys of dictionaries.
- Dictionary disorder
- You can find the specified element by indexing.
- The dictionary supports del deletion.
- For Loop
1. fromkeys
2. get
3. setdefault
4. update