我想做以下事情:
import mymodule
m = mymodule.MyModule()
m.dosth()
# Does something
m.more.domore()
# Does more
mymodule__init__.py文件如下所示:
class MyModule():
def __init__(self):
pass # Constructor
def dosth(self):
print("My module is doing something!")
class more:
def domore(self):
print("My module is doing even more!")
但是当我运行我的脚本时,会出现 TypeError: TypeError: domore() missing 1 required positional argument: 'self。如何在more不出错的情况下从类中调用方法?
慕森卡
largeQ
相关分类