一、语法

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后')

 

相关文章:

  • 2022-03-04
  • 2022-12-23
  • 2021-12-27
  • 2021-11-17
  • 2022-12-23
  • 2022-01-07
  • 2022-12-23
  • 2021-04-13
猜你喜欢
  • 2021-11-22
  • 2021-10-04
  • 2022-01-14
  • 2021-06-29
  • 2022-12-23
  • 2021-04-29
  • 2022-12-23
相关资源
相似解决方案