Simulating trinocular operations using Python's judgment statements

Source: Internet
Author: User
The following said and three mesh operation is a bit similar, but not the same, I do not know how to draw up the title, the first is the title, we all know that there is no three-mesh operation in Python, but and/or a bit similar to the three-mesh operation:
and/or

Use alone to denote a logical relationship with and OR and can also be set and used as follows
and

Before and after if a value is False (false, ', [], {}, None ...) Returns the first false value if all values are true return the last truth
Or

If or any one of the values is true, return this value immediately if all values are false, or returns the last False value
Example

result = ' Test ' and True # result = Trueresult = ' Test ' and ' ortest ' # result = Ortestresult = False and ' ortest ' # result = Falseresult = ' and none # ' result = ' result = ' or ' Hall ' # result = Hallresult = False or None # result = Noneresul t = ' test ' or ' nottest ' # result = Test

Use single-line if else to simulate trinocular operations

Result if true/false else fresult if is true when results are result, false when results are Fresult

result = ' Test ' if True Else ' not test ' # result = ' Test ' result = ' test ' if False Else ' not test ' # result = ' not test '
  • 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.