Python按位分配运算符中的竖线 [英] Vertical bar in Python bitwise assignment operator
本文介绍了Python按位分配运算符中的竖线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有一个代码,在类的方法中有一行:
There is a code and in class' method there is a line:
object.attribute |= variable
我不明白这是什么意思.我没有在基本的Python运算符列表中找到(| =).
I can't understand what it means. I didn't find (|=) in the list of basic Python operators.
推荐答案
这是带有赋值的bitwise or
.等同于
That is a bitwise or
with assignment. It is equivalent to
object.attribute = object.attribute | variable
在更多内容中阅读.
这篇关于Python按位分配运算符中的竖线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文