python学习笔记:(八)条件语句
2024-08-31 23:10:09
if语句,python中if语句的一般形式如下:
conditon1为真,执行statement_block_1
condition1为假,判断conition_2,如果condition_2为真,执行statement_block_2
condition2为假,直接执行statement_block_3
注意:
1、每个条件后,需要使用冒号,标识接下来是满足条件后执行的语句块;
2、使用缩进来划分语句块,相同缩进数的语句在一起组成一个语句块;
3、在python中没有switch--case语句。
如:
if bool==1:
resultstr = (caseapiname, name, wish,"result值:"+str(bool),"成功")
resultmode(','.join(resultstr) + "\n")
elif bool=="":
testresult = result.get("error")
if testresult==wishresult[col]:
resultstr = (caseapiname, name, wish, testresult,"成功")
resultmode(','.join(resultstr) + "\n")
else:
resultstr = (caseapiname, name, wish, testresult,"失败")
resultmode(','.join(resultstr) + "\n")
else:
resultstr =(caseapiname, name, wish,result.get("error"),"失败")
resultmode(','.join(resultstr)+"\n")
最新文章
- phonegap之android原生日历调用
- JQuery_DOM 节点操作之创建节点、插入节点
- 笨办法学 Python (Learn Python The Hard Way)
- WinForm中使用XML文件存储用户配置及操作本地Config配置文件
- A Simple MVVM Example[Forward]
- 两种高性能I/O设计模式(Reactor/Proactor)的比较
- MySQL Error Handling in Stored Procedures---转载
- 生成唯一的id(转)
- Scala基础入门-2
- 2008r2 做windows域控制器
- Spring mvc 转发、重定向
- Opengl4.5 中文手册—A
- PHP 面试时常考的文件操作函数
- windows c++程序移植到linux的要点
- Android 之dragger使用
- [dev][crypto][strongswan] 有关strongswan的forward policy的源码分析
- jQuery - Detect value change on hidden input field
- Picture POJ - 1177(扫描线求面积并)
- iOS - UIAlertController三种显示提示框代码
- MySQL:安装mysqld系统及基础应用