简体   繁体   中英

Is assignment an operator in Python?

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)?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM