猿问

Python:烧瓶从当前目录导入文件,但子类别

我正在努力导入一个包含许多我需要使用的引擎的文件夹。我从main_file.py. 所以我想我可以使用 - from engines import qr_code_gen,但我需要导入一个命名的类, _QRCode_所以我尝试使用 - from .engines.qr_code_gen import _QRCode_,但它说“找不到模块引擎”。


结构:


Server/start.sh

Server/wsgi.py

Server/application/main_file.py

Server/application/engines/qr_code_gen.py

Server/application/engines/__init__.py

...

我用过sys.path,main_file.py我得到了-

['C:\Users\Dzitc\Desktop\winteka2', 'C:\Users\Dzitc\AppData\Local\Programs\Python\Python37\Scripts\flask.exe', 'c:\users\dzitc\appdata\local \programs\python\python37\python37.zip', 'c:\users\dzitc\appdata\local\programs\python\python37\DLLs', 'c:\users\dzitc\appdata\local\programs\python\python37 \lib', 'c:\users\dzitc\appdata\local\programs\python\python37', 'C:\Users\Dzitc\AppData\Roaming\Python\Python37\site-packages', 'c:\users\ dzitc\appdata\local\programs\python\python37\lib\site-packages', 'c:\users\dzitc\appdata\local\programs\python\python37\lib\site-packages\win32', 'c:\ users\dzitc\appdata\local\programs\python\python37\lib\site-packages\win32\lib', 'c:\users\dzitc\appdata\local\programs\python\python37\lib\site-packages\Pythonwin ']

largeQ
浏览 120回答 1
1回答

蛊毒传说

从评论中,您可以导入引擎包。那么试试这个:import enginesengines.qr_code_gen._QRCode_
随时随地看视频慕课网APP

相关分类

Python
我要回答