this article illustrates the way Python implements the same point of finding two dictionaries. Share to you for your reference, as follows:

**: ** to find the same place among two dictionaries (the same key, the same value)

** solutions: ** through `keys (`

) or `items ( method to perform common set operations (such as computing the union, intersection and `

```
```

> > > a={'x': 1,'y': 2,'z': 3} > > > b={'ww': 10,'x': 11,'y': 2} > > > & b.keys ((a.keys) #) key intersection {'y','x'} > > > a.keys) - (b.keys) (# key difference set {'z'} > > > a.keys (b.keys) | (#) keys and the set of {'ww','y','x','z'}, > > > & b.items (a.items) () {('y', 2 }) > > > a.items (b.items) - () {('z', 3), ('x', 1)} > > > a.items (b.items) | () {('ww', 10), ('z', 3), ('x', 1), ('x', 11), ('y', 2)} > > >

< p> these types of operations can also be used to modify or filter out the contents of the dictionary. For example:

> > > C = {key:a[key] for key in a.keys (-{'w'),'z'}} # create a new dictionary to remove some key > > > C, {'y': 2,'x': 1} > > >

** **

` summary: Dictionary (keys) `

`items (`

) method, method of support set operation, but `values (`

) method is not supported. Because in the dictionary from a value point of view, it is not guaranteed that all values are unique, which causes some set operations to have problems. But this can be done by converting values into collections.

("Python Cookbook")

more Python on the relevant content of interested readers can see the special station: "Python data structure and algorithm tutorial " and "Python ", summarizes the skills in the use of function "Python " string manipulation skills summary, "Python entry and advanced tutorial classic " and "Python

operation skills summary" hope for all the Python programming help.

#### you might be interested in this article:

- Python "
- Python Cookbook (data structure and algorithm) let dictionary maintain an orderly method of
"Python

- Python (Cookbook Data structure and algorithm) in the dictionary, the key is mapped to multiple methods on the value of
- Python Dictionary (Dictionary)
- python two traversal the dictionary (dict) method of
- python extraction key list
- Pytho N Cookbook (data structure and algorithm) to find the maximum or minimum N elements for example
- Python Cookbook (data structure and algorithm) to save the last N elements of the
- Python cookbook from iterables in arbitrary length (data structure and algorithm) from the arbitrary length of the iterative operation example
- Python Cookbook (data structure and algorithm) will be decomposed into separate variable method
< / ul>

This concludes the body part

This paper fixed link:http://www.script-home.com/python-cookbook-data-structure-and-algorithm-implement-the-method-of-finding-the-same-points-of-two-dictionaries.html | Script Home |** +Copy Link **

Article reprint please specify:Python Cookbook (data structure and algorithm) implement the method of finding the same points of two dictionaries | Script Home