Python中的赋值运算符是吗? [英] Is assignment an operator in Python?

查看:58
本文介绍了Python中的赋值运算符是吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我检查了Python 3中的运算符优先级( https://docs.python.org/3/reference/expressions.html#operator-precedence ),发现没有分配(=).

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(=).

我想知道分配是否是运算符.如果没有,为什么在Google搜寻时会有这么多的赋值运算符"信息?与其他实际运算符(布尔运算符,比较运算符等)的优先关系是什么?

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

推荐答案

否.分配始终是Python中的一条语句.

No. An assignment is always a statement in Python.

这就是为什么在Python中禁止诸如if语句中的赋值之类的事情(在某些其他语言中是可接受的)的原因.

That's why things like assignment within if statements, which is acceptable in some other languages, is forbidden in Python.

这篇关于Python中的赋值运算符是吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆