pyhton基础知识——if语句
作者:互联网
1.if-elif-else结构
>>> age=12 >>> if age < 4: ... price = 0 ... elif age < 18: ... price = 5 ... else: ... price = 10 ... >>> price 5
- 可省略else代码块
2.使用if判断列表是否为空
>>> str = [] >>> if str: ... a = 1 ... else: ... a = 0 ... >>> a 0
标签:语句,...,elif,price,else,pyhton,str,基础知识,age 来源: https://www.cnblogs.com/my16/p/15028626.html