Basic magic of the dictionary

1.clear

2.copy Shallow copy

3.dict.fromkeys() Generate each key and value from the elements in parentheses, the first parameter is the key, and the second parameter is the value

4. get because if there is no index, an error will be reported. Using this will prompt you that there is no such element, none

5.items

6.keys

7.values

8.pop deletes an element, and the deleted element can be displayed. You can use popitem to delete the key-value pair, but you cannot add parameters. A key-value pair will be deleted at the same time, but the deleted key-value pair can be obtained.

9.setdefault sets the value, if it already exists, it will not be set but the current value will be obtained. If it does not exist, it will be added.

10.update update the dict, you can modify and add dic.update(k1=12,k2="df") python will automatically convert the content in the brackets into a dictionary

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325205301&siteId=291194637