[英]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.