【发布时间】:2021-04-08 11:05:11
【问题描述】:
我想从 subdir 导入一个文件,我收到这样的错误:
ModuleNotFoundError: 没有名为“特殊”的模块
│
├── constants.py
├── crawler.py
├── case.py ===================>>>> I working on this file
├── special
├── __init__.py
└── wantToImport.py =================>>>I want to import this file
我的 case.py 是这样的:
from special.wantToImport import ImportClass
我的 wantToImport.py 文件是这样的:
class ImportClass:
def mydefination(self):
#Some codes here
我想在我的 case.py 文件上使用 mydefinitioon 函数但是我无法导入这个文件。 为什么我收到此错误? 我该如何解决这个问题?
【问题讨论】:
-
这能回答你的问题吗? Importing files from different folder
标签: python python-3.x