Is assignment an operator in Python?

本小妞迷上赌 提交于 2019-12-24 11:01:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!