python - 条件语句

#-*- coding:utf-8 -*-
# author:jiaxy
# datetime:2018/11/3 11:27
# software: PyCharm Community Edition


# 条件语句
# 根据不同的条件,对不同的情况,做出不同的处理
# if 条件表达式:值为布尔值
# if后面的表达式为True,才会执行if后面的子代码

score = 80
if score > 95:
print('优秀')
elif 95 > score >= 80:
print('良好')
elif 80 > score >= 60:
print('及格')
else:
print('没及格')

s = 'PUBG'
if 'B' in s:
print('B is exists')

# 所有为空的数据/为0的数据 ,放在if后面,都会判断为False
# 所有非空的数据,放在if后面,就会判断为True
a = ''
if a:
print('WTF!?')

猜你喜欢

转载自www.cnblogs.com/gotesting/p/9900251.html