if 语句 好像很好理解,就是
if
elif
在if 里加入程序第一反应,然后是各种其他情况的处理。小游戏如下
x = int(input("Please enter an integer: "))
Please enter an integer: 42if x < 0:
… x = 0
… print(‘Negative changed to zero’)
… elif x == 0:
… print(‘Zero’)
… elif x == 1:
… print(‘Single’)
… else:
… print(‘More’)
…
More
int函数可以将一个指定进制的数字型字符串或者十进制数字转化为整形。