Python merges multiple dictionaries to form a dictionary

Source: Internet
Author: User

From collectionsImport Chainmap
Import Collections
Value = Chainmap ()
For List_numInchRange1,13):
Li_list = List_num +1
value["li_name%s"% (list_num)] = Li_list
Value=Value.new_child ()#添加字典到集合
value= value.parents #取出一个空字典
print ( value) #打印合并后的字典
print (dict ( Value) #从对象中提取字典

+++++++++++++++++++++++++++++++++++++ ++++++++++
C:\python3.7\python.exe d:/python-test/stuproject/stuapp/tests.py
Chainmap ({' li_name1 ': 2, ' Li_ Name2 ': 3, ' Li_name3 ': 4, ' li_name4 ': 5, ' li_name5 ': 6, ' Li_name6 ': 7, ' Li_name7 ': 8, ' Li_name8 ': 9, ' li_name9 ': ten, ' Li_n Ame10 ': One, ' li_name11 ':, ' li_name12 ': +} '
{' li_name1 ': 2, ' li_name4 ': 5, ' li_name11 ': +, ' li_name2 ': 3, ' li_name1 2 ': +, ' li_name7 ': 8, ' Li_name8 ': 9, ' li_name5 ': 6, ' li_name10 ': One, ' Li_name3 ': 4, ' li_name9 ': Ten, ' Li_name6 ': 7}

Python merges multiple dictionaries to form a dictionary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.