|
|---hc
| -----a.py
|---util
| -----b.py
|
如果a 要访问b,那么在a.py这么写就好
from util import b as utilb
这样就能用utilb. xxx 调用b里面的方法了
当命令行单独执行某个py脚本时,提示找不到module, 在文件的开始处添加
import sys
import os
sys.path.append(os.path.dirname(sys.path[0]))

|
|---hc
| -----a.py
|---util
| -----b.py
|
如果a 要访问b,那么在a.py这么写就好
from util import b as utilb
这样就能用utilb. xxx 调用b里面的方法了
当命令行单独执行某个py脚本时,提示找不到module, 在文件的开始处添加
import sys
import os
sys.path.append(os.path.dirname(sys.path[0]))
本文标题:python 不同文件夹的py互相访问
本文链接:https://www.haomeiwen.com/subject/whhhhltx.html
网友评论