Python Multiple Assignment Statements In One Line

后端 未结 4 1932
不知归路
不知归路 2020-12-02 20:35

(Don\'t worry, this isn\'t another question about unpacking tuples.)

In python, a statement like foo = bar = baz = 5 assigns the variables foo, bar, and

4条回答
  •  春和景丽
    2020-12-02 20:50

    https://docs.python.org/3/reference/simple_stmts.html#grammar-token-assignment_stmt

    An assignment statement evaluates the expression list (remember that this can be a single expression or a comma-separated list, the latter yielding a tuple) and assigns the single resulting object to each of the target lists, from left to right.

提交回复
热议问题