True in Python and 1 and false and 0 are equivalent comparisons

Source: Internet
Author: User

True in Python and 1 and false and 0 can be compared in equivalent
The test is as follows:

[email protected] root]# cat test_true_false.py

Ok=0
If OK:
Print OK
Ok=1

If OK:
Print OK
Ok=true

If OK:
Print OK
Ok=false

If OK:
Print OK

print ' * ' *20

Ok=0
If ok = = False:
Print OK

Ok=1
If ok = = True:
Print OK

Ok=false
If OK ==0:
Print OK

Ok=true
If ok = = 1:
Print OK
[Email protected] root]#

[email protected] root]# python test_true_false.py
1
True
********************
0
1
False
True
[Email protected] root]#

This article is from the "Wish" blog, please be sure to keep this source http://xinyuan8.blog.51cto.com/677906/1640333

True in Python and 1 and false and 0 are equivalent comparisons

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.