The dictionary object is actually the addition, modification, and deletion of the dictionary object below the key-value pair (the modification is the same as the addition method and is added when the key value does not exist) IDLE 3.0
>>> Dic = {"aa": 1, "bb": 2, "AB": 3}
>>> Dic
{'A': 1, 'AB': 3, 'BB': 2}
>>> For k in sorted (dic. keys ()):
Print (k)
Aa
AB
-----------------------------------------------
The dictionary object is actually a key-value pair.
The following describes how to add, modify, and delete dictionary objects.
(The modification is the same as the addition method. if the key value does not exist, add it)
>>> Dic ["cc"] = 4
>>> Dic
{'A': 1, 'CC': 4, 'AB': 3, 'BB': 2}
>>> Dic ["bc"] = 5
>>> Dic
{'A': 1, 'CC': 4, 'AB': 3, 'BB': 2, 'BC': 5}
>>> Dic ["cc"] = 6
>>> Dic
{'A': 1, 'CC': 6, 'AB': 3, 'BB': 2, 'BC': 5}
>>> Del dic ["cc"]
>>> Dic
{'A': 1, 'AB': 3, 'BB': 2, 'BC': 5}
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