If 多条件判断
1、使用and 进行多条件判断运算(并运算)
eg:
- if txt != '标题' and txt != '':
- print('总价', line[4])
- unitPrice = 0
- Price = 0
- if line[4].find('万') > 0:
- Price = str2value(line[4])
- print('是否包含万', str2value(line[4]))
- if line[5].find('元/平') > 0:
- unitPrice = int(str(line[5].replace('元/平', '').replace(',', '')))
- print('是否包含元/平', int(str(line[5].replace('元/平', '').replace(',', ''))))
- print('单价', line[5])
- print(line)
2、使用or 进行多条件判断运算(或运算)
eg:
- if passwd == '123456' or passwd == 'abcdef'
- print('密码正确')
3、使用elif进行多条件判断运算
eg:
- if user == 'man';
- print('男孩')
- elif user == 'girle':
- print('女孩')
if 支持判断条件
if 语句的判断条件可以用>(大于)、<(小于)、==(等于)、>=(大于等于)、<=(小于等于)来表示其关系。