Python Learning Dictionary

Source: Internet
Author: User

Python Learning Dictionary

1) Understanding of the dictionary

1. Dictionary is the only mapping type (hash table) in Python

2. The Dictionary object is mutable, but the key of the dictionary must use an immutable object, and a different type of key value can be used in a dictionary.

3. keys () or values () returns the list or value list

4. items () returns the Ganso containing the corresponding key value

1) How to define a dictionary and how to use it

1. Dictionary name ={key:values,key1:values1}

2. Value: dictionary name [key] (take out the values corresponding to key)

3. You can use for traversal of all keys and values

4. Add the key in the dictionary and the corresponding values:

Dictionary name [key]=values

5. Modify the value: dictionary name [key]=values

6. Delete one of the values:

1] del (dictionary name [key])

2] Dictionary name pop (key) pops its value (that is, delete this value)

3] Clears the dictionary name. Clear () The dictionary is an empty dictionary at this time

7. Built-in functions and corresponding methods:

Type () str () CMP ()

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/49/27/wKioL1QQBcSDfZdEAAR2f4Rv_Jc186.png "title=" capture. PNG "alt=" Wkiol1qqbcsdfzdeaar2f4rv_jc186.png "/>

Python Learning 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.