Fourth Chapter: Dictionary

Source: Internet
Author: User

The dictionary is the only built-in mapping type in Python; its keys can be numbers, strings, or tuples;

The key and value are separated by a colon and a comma between the items;

(1) Dict (List of tuples)!!! ), or constructed by means of a key= value, (2) Len (d), D[k],del D[k], k in d//K;

(3) about the format output of the dictionary, "Ceil's phone number is% (ceil) s."% xxxx set the key to the value!

(4) Clear () deletes the data, not the index. (5) Copy is still not clear, need processing!!

(6) Fromkeys ([xx,xx]); Creates a key-value pair with the given key. (7) Get (key), used instead of direct access to the problem, in the absence of a corresponding key, you can easily return to none, or the specified key.

(8) D.has_key (k) equivalent to K in D (9) Item, returns the list of corresponding tuples

(ten) Pop (' key ') (one) Popitem will return a random item in a tuple (a) SetDefault when there is no stored key, value, press the key value, if the key has a value without modification, similar to the Get method;

Update updates another dictionary with one dictionary

Fourth Chapter: 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.