004 dictionary,
Ing type
# Definition
Integer type will create a new space in the memory
Dic = {[2, 3]: 'alow', 'age': 35, 'hobby': 'meizi', 'is _ handsome': True,} # The variable value cannot be a key.
Use braces to create and use more
Create with dict ()
Dic2 = dict ('name', 'Alex '),))
# Add a key
Dic. setdefault ('airen', 'clear ')
If yes, no value is added. If no value is added, all values are returned.
# Query
Dic. keys ()
View All keys and store a keys type, not a list. You can convert them to a list.
Dic. values () view value
Dic. items ()
# Change
Dic2 = {'1': '123 '}
Dic. update (dic2)
If the same key exists, it will overwrite
# Delete
Dic. clear ()
Del dic ['name']
A = dic. pop ('name ')
# Dictionary nesting # Picture content is purely funny
The dictionary has more keys.
# Sorting
Print (sorted (dic. values ()))
# Traversal
For I indic:
Print (I, dic [I], end = '')
# String to list
Str = '1, 2, 3'
Arr = str. split (',')