我是在ATTransferable.py里报错的
EditorBuilder.py
from abc import ABC,abstractmethod
class EditorBuilder(ABC):
def __init__(self):
self.lines = None
self.filepath = None
@abstractmethod
def operation(self,rootpath,gameconstants):
pass
Decorator.py
from EditorBuilder import EditorBuilder
from utils import IO
class Decorator(EditorBuilder):
def __init__(self,editorbuilder):
super().__init__()
self.editorbuilder = editorbuilder
self.rootpath = None
self.gameconstants = None
# def __init__(self):
# EditorBuilder.__init__()
# self.editorbuilder = None
# self.rootpath = None
# self.gameconstants = None
def operation(self,rootpath,gameconstants):
self.editorbuilder.operation(rootpath, gameconstants)
def instance(self,rootpath,gameconstants):
self.rootpath = rootpath
self.gameconstants = gameconstants
def input(self):
super.lines = IO.readlines(self.filepath)
def ouput(self):
IO.writelines(super.lines, self.rootpath)
ATTransferable.py
from model.Decorator import Decorator
from model.EditorBuilder import EditorBuilder
from utils import IO
import os
class ATTransferable(Decorator):
def __init__(self, eb):
super(eb).__init__(eb)
def treat(self):
IO.replaceinline("Transferable 0","Transferable 1",self.lines)
def operation(self,rootpath,gameconstants):
result = self.editorbuilder.operation(rootpath,gameconstants)
filepath1 = os.path.join(rootpath,'data','export_descr_ancillaries.txt')
self.filepath = filepath1
self.input()
self.treat()
self.output()
print("ATTransferable")
return result + "_ATTransferable"
报错信息
D:\PF\program\Anaconda3\python.exe F:/work/program/python/MedievalTotalwar/TextM2TW/ATTransferable.py
Traceback (most recent call last):
File "F:\work\program\python\MedievalTotalwar\TextM2TW\ATTransferable.py", line 1, in <module>
from model.Decorator import Decorator
File "F:\work\program\python\MedievalTotalwar\model\Decorator.py", line 1, in <module>
from EditorBuilder import EditorBuilder
ModuleNotFoundError: No module named 'EditorBuilder'
Process finished with exit code 1
我不是都导入了怎么会报错?
需要看报错的堆栈信息,显示的时Decorator.py中import EditorBuilder找不到。
Decorator.py中引入时加个model:
from model.EditorBuilder import EditorBuilder