"Python"--Dictionary

Source: Internet
Author: User

# "dictionary"    #映射    #字典是无序存储的, no positional relationship    print (ID (a))   #打印a的内存地址    #不可变类型: Integer, String, tuple    #可变类型: list, dictionary Dictionary = {' name ': ' Zhangw ', ' age ': +, ' isboy ': True,} dictionary2 = {' name ': ' Haha ', ' What ': ' Qie '}    #字典可以做值, cannot do key # Dictionary name {key: Value, key: Value} #字典两大特点            #无序    #键唯一    #增加    dictionary[' name '] =    dictionary[' haha ') = ' new '    ret= Dictionary.setdefault (' age ', +) #键存在, does not change, returns the corresponding value in the dictionary, the key does not exist, adds a new key-value pair in the dictionary, and returns the corresponding value    #查找        #通过键        Print ( dictionary[' name '])        print (Dictionary.keys ()) #查找键            #查找出来的是dict_key类型        print (Dictionary.values ())        print (Dictionary.items ())     #修改        dictionary.update (dictionary2)    #删除        del dictionary[' name '] #根据键删除        dictionary.clear () #清空字典        del.dictionary #删除整个字典 #排序         sorted (dictionary)

"Python"--Dictionary

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.