Liaoche Python excerpt 3

Source: Internet
Author: User

1, if Judging conditions can also be abbreviated X. As long as a non- x 0 value, a non-empty string, a non-empty list, etc., it is judged True , otherwise False .

2. This is because the input() returned data type is str str not directly compared to an integer and must first be str converted to an integer. Python provides a int() function to do this thing:

s = input (' Birth: ') birth = Int (s) if birth <:    print (' 00 ago ') Else:    print (' 00 ')

Or s> ' 2000 ' is also possible, requiring a consistent type to compare.

要是int()function to find a string is not a valid number when the error occurs, the program exits.

Liaoche Python excerpt 3

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.