Python-is and = =

Source: Internet
Author: User

The first thing to know is that the three basic elements in Python are: ID (Identity), type (data type), and value.

= = is a comparison operator in the python operator that is used to compare the value of two objects for equality

For example:

A = ' abc '

b = ' abc '

Print a ==b >>>>true

Is is also called the identity operator, which compares the unique identities between objects, that is, whether the IDs are the same.

For example:

A = [A]

b = [[+]

Print ID (a), id (b) >>>>4389046392, 4389177464

Print A is B >>>>false

Only numeric and string Types , A is B are true, when a and B are tuple,list,dict or set type, a IS-B is false



Very no idea.
Links: https://www.jianshu.com/p/a41ad2ff2963
Source: Pinterest
The copyright of the book is owned by the author, and any form of reprint should be contacted by the author for authorization and attribution.

Python-is and = =

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.