zoukankan      html  css  js  c++  java
  • python学习之分支和循环

    1.条件表达式之“三元操作符”:

    s = x if 条件 else y

    条件为假,把y赋值给s;条件为真,x赋值给s。

    2.assert 断言:

    assert后面的条件为真,则不提示;

    assert后条件为假,则提示“assertion error”,可以后期捕获并处理异常

    3.while循环:

    while 条件:

      循环体

    4. for 循环:

    for 目标 in 表达式:

      循环体

    5.range():

    range(参数1,参数2,step)

    如:range(1,10,2) 从1开始,每次增加2

    range(5),应该是0、1、2、3、4,注意:不包含5

    一般与for循环配合使用

    6.break和continue

    break终止循环,跳出循环体

    continue 终止本次循环,开始下次循环

  • 相关阅读:
    asy for
    asy html !
    lib
    git clone 指定 version tag
    git tag
    git clone <url>--depth 、 git clone <url> --recursive
    xelatex CLI
    rsync
    curl options
    [转自]C语言offset_of宏和container_of宏
  • 原文地址:https://www.cnblogs.com/zoeya/p/8549658.html
Copyright © 2011-2022 走看看