![](/img/trans.png)
[英]Importing modules that import other modules from other directories in Python 3.6
[英]How to Import Multiple Python Modules from Other Directories
Python新手在这里。 任何和所有关于python结构的帮助将非常感谢!
主要问题:如何从其他目录导入多个Python模块
我重新组装了一个项目的存储库,以便根据任务类型而不是仅仅一个巨大的文件夹,将特定任务的模块放在各个文件夹中。 因为我的模块都在一个文件夹中,所以我以前能够以这种方式轻松导入:
import sys
sys.path.insert(0,'/home/myname/folder_name/all_modules')
现在,我有四个模块文件夹。
我想将其中两个模块导入script_to_run.py 。
我尝试过的东西不起作用:
import sys
sys.path.insert(0,'/home/myname/folder_name/email_modules')
sys.path.insert(0,'/home/myname/folder_name/gen_modules')
我在过去的三个小时里读了很多,但我仍然对如何继续感到困惑。 任何指导,包括我可能没有遇到的有用链接,将不胜感激。 谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.