Python Learning Dictionary
1) Understanding of the dictionary
1. Dictionary is the only mapping type (hash table) in Python
2. The Dictionary object is mutable, but the key of the dictionary must use an immutable object, and a different type of key value can be used in a dictionary.
3. keys () or values () returns the list or value list
4. items () returns the Ganso containing the corresponding key value
1) How to define a dictionary and how to use it
1. Dictionary name ={key:values,key1:values1}
2. Value: dictionary name [key] (take out the values corresponding to key)
3. You can use for traversal of all keys and values
4. Add the key in the dictionary and the corresponding values:
Dictionary name [key]=values
5. Modify the value: dictionary name [key]=values
6. Delete one of the values:
1] del (dictionary name [key])
2] Dictionary name pop (key) pops its value (that is, delete this value)
3] Clears the dictionary name. Clear () The dictionary is an empty dictionary at this time
7. Built-in functions and corresponding methods:
Type () str () CMP ()
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/49/27/wKioL1QQBcSDfZdEAAR2f4Rv_Jc186.png "title=" capture. PNG "alt=" Wkiol1qqbcsdfzdeaar2f4rv_jc186.png "/>
Python Learning Dictionary