更新时间:2023-02-09 23:27:15
您需要更新您的 sys.path
,这是python查找模块的地方,而不是你当前环境中的系统路径,这就是os.environ["PATH"]
指的是.
You need to update your sys.path
, which is where python looks for modules, as opposed to your system's path in the current environment, which is what os.environ["PATH"]
is referring to.
示例:
import os, sys
sys.path.insert(0, os.path.abspath(".."))
import aa
这样做之后,你可以像这样在 aa
中使用你的函数:aa.myfunc()
After doing this, you can use your functions in aa
like this: aa.myfunc()
接受的答案中有更多关于python:从目录导入模块