python如何优雅的合并字典

2018-07-06  本文已影响0人  zhnidj

def merge_dicts(*dict_args):

""" Given any number of dicts, shallow copy and merge into a new dict, precedence goes to key value pairs in latter dicts. """

        result = {}

        for dictionary in dict_args:

                result.update(dictionary)

        return result

label=merge_dicts(label1,label2,label3,label4,label5,label6)

上一篇 下一篇

猜你喜欢

热点阅读