在跨类调用的时候 我想直接创建对象
class Person:
def __init__(self, name):
self.name = name
def clean(self, cleaner):
cleaner.sweep()
print(f"保洁阿姨去{self.name}家打扫卫生", end="")
class Notify:
def __init__(self):
self.name1 = Person()
def sweep(self):
print(f"{self.name1.name}通知保洁阿姨打扫卫生")
Xm = Person("小明")
cleaner = Notify()
Xm.clean(cleaner)
Traceback (most recent call last):
File "/home/tarena/month01/day10/exercise3.py", line 49, in <module>
cleaner = Notify()
File "/home/tarena/month01/day10/exercise3.py", line 45, in __init__
self.name1 = Person()
TypeError: Person.__init__() missing 1 required positional argument: 'name'
######暂时没想到什么解决办法