【发布时间】:2019-12-28 12:58:33
【问题描述】:
我想为字典编写+ 运算符。
我知道在like here 之前有人问过类似的问题,但我想为字典编写+ 运算符。
我知道可以在 Python 的自定义类中重载运算符。但是我没有找到如何在内置类中重载运算符(如果这实际上可能的话)。另外,由于没有为 Python 中的字典定义 + 运算符,我想知道这是否可能?
我认为这个问题以前没有在 SO 上被问过,因为我找不到类似的东西。也许我只是没有找到合适的术语来搜索它。 Another link that might be useful for that question.
【问题讨论】:
-
不,但是是的,请查看此示例:stackoverflow.com/questions/6738987/…
标签: python dictionary operator-overloading operators