问题
I checked the operator precedence in Python 3(https://docs.python.org/3/reference/expressions.html#operator-precedence), and found that there is no assignment(=).
I want to know if assignment is an operator or not. If not, why there are so many "assignment operator" info when googled? What is the precedence relation with other real operators(bool operator, comparison operator, etc)?
回答1:
No. An assignment is always a statement in Python.
That's why things like assignment within if statements, which is acceptable in some other languages, is forbidden in Python.
来源:https://stackoverflow.com/questions/46180894/is-assignment-an-operator-in-python