Python dictionary --- one key and multi-value, dictionarykeyvalue

Source: Internet
Author: User

Python dictionary --- one key and multi-value, dictionarykeyvalue

Pairs of keys and value are specified in a dictionary by using the notation d = {key1: value1, key2: value2 }.

One key and multi-value AB = {key1: (value1, value2 ),

Key2: (value3, value4 )}

 

AB = {'xiaopeng yang': (18000001219, '2017 @ 139.com ')}

AB ['qiping kong '] = (1590100007, '2017 @ qq.com ')
For name, (phone, email) in AB. items ():
Print 'Contact % s phone number is % d, email address is % s' % (name, phone, email)

 

Output:

====================== RESTART:/Users/zhouxin/Desktop/test. py =
Contact Qiping kong phone number is 1590100007, email address is 000004369@qq.com
Contact Xiaopeng Yang phone number is 18000001219, email address is 18700000019@139.com
>>>

 

Related Article

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.