2024-04-25 07:31:46 发布
网友
Python's documentation没有提到=的运算符优先级。那是什么?你知道吗
=
=不是运算符。=是assignment statement。你知道吗
因为它是一个语句,所以它不能是表达式的一部分(表达式是某些语句的一部分,而不是相反),所以排序是不相关的。表达式总是被执行以提供语句。你知道吗
对于赋值,语法指定在=符号之后允许特定类型的表达式:
assignment_stmt ::= (target_list "=")+ (starred_expression | yield_expression)
该语句的文档详细说明了执行的顺序:
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.
=
不是运算符。=
是assignment statement。你知道吗因为它是一个语句,所以它不能是表达式的一部分(表达式是某些语句的一部分,而不是相反),所以排序是不相关的。表达式总是被执行以提供语句。你知道吗
对于赋值,语法指定在
=
符号之后允许特定类型的表达式:该语句的文档详细说明了执行的顺序:
相关问题 更多 >
编程相关推荐