以下是我的代码片段。当我运行程序时,它给了我以下错误。
@functools.total_ordering
AttributeError: 'module' object has no attribute 'total_ordering'
我正在使用 python 3.1
import functools
@functools.total_ordering
class Abs(object):
def __init__(self,num):
self.num=abs(num)
def __eq__(self,other):
return self.num==abs(other.num)
def __lt__(self,other):
return self.num < abs(other.num)
five=Abs(-5)
four=Abs(-4)
print(five > four)
导入语句中是否缺少某些内容?