比较原则
- 比较相等:== 区分大小写
- 比较不相等:!=
- 检查多个条件:and(类似&&)、or(类似||)
- 检查特定值是否在列表中:in(在列表中)、not in(不在列表中)
if语句
if condition_test:
do something
if-else语句
if condition_test:
do something
else:
do another thing
if-elif-else语句
if condition_test_1:
do something_1
elif condition_test_2:
do something_2
else:
do another thing
- 可以使用多个elif代码块
- 也可以省略else代码块
- 使用时,只会执行某一分支里的语句