Python学习笔记(六)—— 条件判断

一、语法

if <条件判断1>:
    <执行1>
elif <条件判断2>:
    <执行2>
elif <条件判断3>:
    <执行3>
else:
    <执行4>

1、注意不要少了冒号

2、语句结束时,不需要有;号

二、再议input

    这是因为input()返回的数据类型是strstr不能直接和整数比较,必须先把str转换成整数。Python提供了int()函数来完成这件事情:

s = input('birth: ')
birth = int(s)
if birth < 2000:
    print('00前')
else:
    print('00后')
原文地址:https://www.cnblogs.com/BlueMountain-HaggenDazs/p/6349453.html