How to quickly find more dictionaries public key (Key) --- Python data structures and algorithms related issues and solving skills

How to quickly find more dictionaries public key (Key) -?

 

actual case:

 Spanish Football League, scoring each round player statistics:

  Round 1: { 'Suarez': 1, 'Massey': 2 'Benzema': 1, ...}

  Round 2: { 'Suarez': 1, 'Lo C': 2 'Juggernaut': 1, ...}

  Round 3: { 'Suarez': 1, 'Carl': 2 'Bailey': 1, ...}

  ...

  Statistics of the N front wheel, every game player to score.

 

  --N a dictionary, looking for problems common bond -

 

Relatively easy to think of ways:

 

our way: 

solution:

  Use the set (set) intersection operation --- get all dict public key

 Step1:

  Use dictionary keys () method, to obtain a set of keys dictionaries   

     - For two dictionaries are calling keys, you can get two sets, two sets to do with the intersection of operation, the result of the intersection, is the public key

 Step2:

  For more dictionaries:

  Use Map function to obtain a set of keys for each dictionary

 Step3:

  Reduce the use of the intersection of function, take all dictionary keys collection 

 

 

Guess you like

Origin www.cnblogs.com/goddog1024/p/11267307.html