假如dir1目录下包含一个a.py文件,你的目标文件在dir2文件,你想将a.py import到你的目标文件中,可以通过如下方法: import sys; sys.path.append("dir1") import a