Compare dictionary sizes with CMP in Python

Source: Internet
Author: User

    1. Dictionary length

      The dictionary dic1,dic2 values, and the comparison results are as follows:

      650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/5A/65/wKiom1T8WleC2rRYAAB-yg7JBdg034.jpg "title=" QQ picture 20150308221727.png "alt=" Wkiom1t8wlec2rryaab-yg7jbdg034.jpg "/>

      The longer the dictionary length, the larger the dictionary.

      Question one: If the length is different, the length is longer but the key value is smaller, that big?

      650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/5A/65/wKiom1T8W5uRddAwAACIGsqRC7M028.jpg "title=" QQ picture 20150308222301.png "alt=" Wkiom1t8w5urddawaacigsqrc7m028.jpg "/>

      Answer: Dictionary length is the first comparison, long length of the big

    2. Equal length, compare keys

Question two: If the key is not the same and relatively small, but the Valuse value is big?

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5A/61/wKioL1T8YEKytfxSAABzAjglxnk639.jpg "style=" float: none; "title=" QQ picture 20150308223621.png "alt=" wkiol1t8yekytfxsaabzajglxnk639.jpg "/> 650" this.width=650; "src=" http ://s3.51cto.com/wyfs02/m01/5a/65/wkiom1t8xyjqy_ahaab2jot1tzc792.jpg "title=" qq picture 20150308223652.png "alt=" Wkiom1t8xyjqy_ahaab2jot1tzc792.jpg "style=" float:none; "/>

If the key value is not the same, the dictionary with large key value is large.

3. Equal length and equal key values, then compare dictionary values

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/5A/61/wKioL1T8Xb3Qg_E0AACOCUXBjoM165.jpg "title=" QQ picture 20150308222720.png "alt=" Wkiol1t8xb3qg_e0aacocuxbjom165.jpg "/>


In the case of equal lengths: Compare the first valuse,valuse value to the large one, and the second valuse for equality.

Question three: If the value is a string, the strings have equal, but one of them is longer

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/5A/65/wKiom1T8ZaqQCfmFAACbObREd4w594.jpg "title=" QQ picture 20150308230539.png "alt=" wkiom1t8zaqqcfmfaacbobred4w594.jpg "/> Answer: When comparing strings, each letter is compared, you can have the result, if the string is less than the end, But one of the strings is longer, and the string is large.










This article is from the Python comparison dictionary size blog, so be sure to keep this source http://8183737.blog.51cto.com/8173737/1618435

Compare dictionary sizes with CMP in Python

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.