美文网首页
python如何优雅的合并字典

python如何优雅的合并字典

作者: zhnidj | 来源:发表于2018-07-06 15:58 被阅读0次

    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)

    相关文章

      网友评论

          本文标题:python如何优雅的合并字典

          本文链接:https://www.haomeiwen.com/subject/nmhbuftx.html