Error when trying to overload an operator “/”

别说谁变了你拦得住时间么 提交于 2019-11-27 08:51:41
isedev

In Python 3.x, you need to overload the __floordiv__ and __truediv__ operators, not the __div__ operator. The former corresponds to the // operation (returns an integer) and the latter to / (returns a float).

In Python 3, the division operators are called __truediv__ and __floordiv__. See the Data model documentation for more information.

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