python: union keys from multiple dictionary?

后端 未结 5 815
终归单人心
终归单人心 2021-02-12 20:49

I have 5 dictionaries and I want a union of their keys.

alldict =  [dict1, dict2, dict3, dict4, dict5]

I tried

allkey = reduce(         


        
5条回答
  •  深忆病人
    2021-02-12 21:01

    set().union(dict1.keys(),dict2.keys()...)
    

    I tried the list and it didnt work so just putting it up here for anyone.

提交回复
热议问题