三元运算符就是在赋值变量的时候,可以直接加判断,然后赋值

        三元运算符的功能与'if....else'流程语句一致,它在一行中书写,代码非常精炼,执行效率更高

        格式:[on_true] if [expression] else [on_false]

        res = 值1 if 条件 else 值2

 

相关文章:

  • 2021-06-07
  • 2021-09-07
  • 2021-09-26
  • 2021-08-18
  • 2022-12-23
  • 2021-08-12
  • 2021-07-24
  • 2021-12-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-06
  • 2022-12-23
  • 2021-11-27
  • 2023-03-14
  • 2021-06-21
相关资源
相似解决方案