Skip to content

Latest commit

 

History

History
22 lines (16 loc) · 308 Bytes

75.md

File metadata and controls

22 lines (16 loc) · 308 Bytes
@author jackzhenguo
@desc 
@date 2019/4/15

75 合并两个字典

Python 3.5 后支持的一行代码实现合并字典

def merge_dict(dic1, dic2):
    return {**dic1, **dic2} 

测试:

merge_dict({'a': 1, 'b': 2}, {'c': 3}) 
# {'a': 1, 'b': 2, 'c': 3}