我有以下文件安排:
python
|--main.py
|files
|-----folder1
|-----a.py,a1.py.....
|-----folder2
|-----b.py,b1.py....
Run Code Online (Sandbox Code Playgroud)
我想将模块a和b.py导入main.py. 为此,我在main.py中使用了以下命令:
a = 'C:/python/files/folder1'
sys.path.insert(0, a)
from files.folder1 import *
Run Code Online (Sandbox Code Playgroud)
但是,我无法从folder1导入模块(类似于folder2).我收到一个错误:
No module named files.folder1
Run Code Online (Sandbox Code Playgroud)
我不能使用import命令,因为folder1,folder2中有很多python文件......等等.
我在这里错过了什么吗?
python ×1