简体   繁体   English

从python中的另一个文件夹导入文件

[英]Importing files from another folder in python

I am trying to import files from other files.我正在尝试从其他文件导入文件。 I checked out examples but I am still confused.我查看了示例,但我仍然感到困惑。

The structure of the folder is something like:文件夹的结构类似于:

 Main folder
 ---->test.py
 ---->Folder1
      ----> folder2
            -------> script2.1.py
            -------> script2.2.py
            -------> script2.3.py
      ----> folder3
            -------> script3.1.py
            -------> script3.2.py
            -------> script3.3.py
      ----> folder4
            -------> script4.1.py
            -------> script4.2.py
            -------> script4.3.py

My intention is to include script2.1 to script4.3 in test.py .我的意图是在test.py包含script2.1 to script4.3 I used sys.append and included the paths of folder1, folder2 and folder3 separately.我使用了sys.append并分别包含了 folder1、folder2 和 folder3 的路径。 Still there appears to be some issue.看来还是有些问题。 Can I get some help on this?我能得到一些帮助吗?

你做了这个了吗?

  import Folder1.folder2.script2.1.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM