Python dictionary
1. Definition dictionary
2. Form: key-value (key-value)
keywords must be strings
3. List to dictionary
4. Addition
, deletion, modification, and query of dictionary The addition , deletion, modification, and query of the list are all performed on the following.
The dictionary is carried out through the key, because the key is unique in the dictionary.
4.1, add
4.2, change
4.3, check
4.4, delete
5. The built-in function in the dictionary is to use the dictionary to call the function
5.1. items()
5.2 values()
take out all the values in the dictionary and save them in the list
5.3 get() returns value
get(key) ------>value If the value cannot be obtained, no error will be reported, and None will be returned.
get(key, default) ------>value If the value can be obtained, the value in the dictionary will be returned , If not available, it will return the value of default
5.4, pop(key) will return the value corresponding to the key that was successfully deleted
popitem() generally delete the elements of the dictionary one by one from the end
5.5. update()
merges the addition with the new, which is equivalent to the connection of the list []+[], but the dictionary does not have a +. Use update() to merge the two dictionaries
5.6, fromkeys(seq) to
combine the sequence seq (such as a list or a character) String) into the form of a dictionary, if no value is specified, use None
6. Case
User registration function: username, password, Email, phone