Python '//' 类中的整数除法
Python '//' integer division method in classes
如何将整数除法 //
方法添加到 class?
我可以像def __sub__(self, other):
那样加一个减法,那我怎么用//
呢?
我在网上找过这个,找不到任何东西。
使用Python 3.
您正在寻找 __floordiv__
。
如何将整数除法 //
方法添加到 class?
我可以像def __sub__(self, other):
那样加一个减法,那我怎么用//
呢?
我在网上找过这个,找不到任何东西。
使用Python 3.
您正在寻找 __floordiv__
。