The dictionary is the only built-in mapping type in Python.
Create dictionary phonebook = {' Alice ': ' 2341 ', ' Beth ': ' 9102 '}
You can use Dict to build a dictionary from a sequence of other mappings or key-value pairs. Key value parameter to create a dictionary.
The number of items in Len (d) d. D[K] Returns the value associated to the key, d[k] = v assigns the key, Del D[k] the DELETE key k,k in D contains the key K.
Key type, automatically added, membership.
The formatted string of the dictionary.
Method:
1.clear clears all entries in the dictionary. Operate in situ.
2.copy shallow Copy, change the value of the original data has no effect, delete all deleted. Deepcopy deep Copy, no impact.
3.fromkeys creates a new dictionary with the given key, the default value of None
4.get Access Dictionary, if none is returned, there will be no exception.
5.has_key Check if a key value is included in the dictionary
6.items all items are returned in the form of a key-value pair, with no order. Iteritems returns an Iterator object.
The 7.keys list shows all keys, Iterkeys returns an iterator for a key.
8.pop gets the value corresponding to the given key, and then deletes the key-value pair in the dictionary.
9.popitem randomly pops a key value
10.setdefault is similar to the Get method, but it can assign values to non-existent key values.
11.update New Dictionary update old dictionary
12.valus returns the value in the dictionary as a list, itervalues the iterator.
Python Learning notes-dictionaries