python - python 3.9中是否有与|=(管道相等/更新)对应的__dunder__方法?

标签 python python-3.x python-3.9

在python 3.9中,获得的字典组合|并更新 |=运营商。是否有一种 dunder/magic 方法可以将其用于其他类?我试过查看 python 源代码,但发现它有点令人困惑。

最佳答案

是的,||=对应于 __or__ __ior__ .

不看python源码,看文档。尤其是数据模型。

here

请注意,这并非特定于 python 3.9。

关于python - python 3.9中是否有与|=(管道相等/更新)对应的__dunder__方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62375432/

相关文章:

python - 在 python 3.9+ 中,如何使用省略号为内置元组类型编写类型别名? (mypy 错误?)

python - 在 Pycharm 和终端中运行带有参数的 python 脚本

linux - python 3.9.1中decodestrings is not a attribute of base64错误

python - 如何在不绑定(bind) IP 的情况下在特定端口上运行服务

python - pyplot 图例的 Facecolor 不显示

python - 从tensorflow 1.x升级到2.0

python - 我的 Django 应用程序中由 uwsgi 启动的日志记录在哪里?

python - 什么是 "soft keywords"?

python - SQLAlchemy 和 Elixir ?

python - 自动配对和 Python 字符串