|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
class Displayer:
def display(self,message):
print(message)
class loggermixin:
def log(self,message,filename="logfile.txt"):
f.write(message)
def display(self,message):
super().divplay(message)
self.log(message)
class Mysubclass(loggermixin,Displayer):
def log(self,message):
super().log(message,filename="subclasslog.txt")
subclass=MysubClass()
subclass.display("this is a test.")
定义了MysubClass但是显示没有定义,请求大佬帮助
本帖最后由 isdkz 于 2023-2-1 21:43 编辑
class Displayer:
def display(self,message):
print(message)
class loggermixin:
def log(self,message,filename="logfile.txt"):
with open(filename, 'w') as f: # 打开文件
f.write(message)
def display(self,message): # 这个缩进不对
super().display(message) # display 打错了
self.log(message)
class Mysubclass(loggermixin,Displayer):
def log(self,message):
super().log(message,filename="subclasslog.txt")
subclass=Mysubclass() # Mysubclass 的 c 是小写
subclass.display("this is a test.")
|
|