if语句,pythonif语句的一般形式如下:

 python学习笔记:(八)条件语句

  conditon1为真,执行statement_block_1

  condition1为假,判断conition_2,如果condition_2为真,执行statement_block_2

  condition2为假,直接执行statement_block_3

注意:

  1、每个条件后,需要使用冒号,标识接下来是满足条件后执行的语句块;

  2、使用缩进来划分语句块,相同缩进数的语句在一起组成一个语句块;

  3、在python中没有switch--case语句。

如:

 1             if bool==1:
 2                 resultstr = (caseapiname, name, wish,"result值:"+str(bool),"成功")
 3                 resultmode(','.join(resultstr) + "\n")
 4             elif bool=="0":
 5                 testresult = result.get("error")
 6                 if testresult==wishresult[col]:
 7                     resultstr = (caseapiname, name, wish, testresult,"成功")
 8                     resultmode(','.join(resultstr) + "\n")
 9                 else:
10                     resultstr = (caseapiname, name, wish, testresult,"失败")
11                     resultmode(','.join(resultstr) + "\n")
12             else:
13                 resultstr =(caseapiname, name, wish,result.get("error"),"失败")
14                 resultmode(','.join(resultstr)+"\n")

 

相关文章:

  • 2022-01-15
  • 2021-08-18
  • 2021-06-11
  • 2021-07-11
  • 2021-04-23
  • 2021-11-19
猜你喜欢
  • 2022-12-23
  • 2021-11-13
  • 2021-09-10
  • 2021-06-21
  • 2021-06-11
  • 2021-10-07
  • 2021-09-06
相关资源
相似解决方案