Copying a key/value from one dictionary into another

前端 未结 2 984
慢半拍i
慢半拍i 2021-01-12 08:29

I have a dict with main data (roughly) as such: {\'UID\': \'A12B4\', \'name\': \'John\', \'email\': \'hi@example.com}

and I have another dict like:

2条回答
  •  臣服心动
    2021-01-12 09:17

    If you want to join dictionaries, there's a great built-in function you can call, called update.

    Specifically:

    test = {'A': 1}
    test.update({'B': 2})
    test
    >>> {'A':1, 'B':2}
    

提交回复
热议问题