我如何使用__str__其他类的多个?例如:
class A:
def __str__(self):
return "this"
class B:
def __str__(self):
return "that"
class C(A,B):
def __str__(self):
return super(C, self).__str__() + " those"
# return something(A) + " " something(B) + " those"
cc = C()
print(cc)
Run Code Online (Sandbox Code Playgroud)
输出:这些
我希望输出为:这就是那些
这篇文章几乎是一个解决方案(有super())