-1

G:\code\Python\hello\helloworld.py

G:\code\Python\hello\mymodule\gettime.py

G:\code\Python\hello\mypath.pth

我写gettime.pymymodule我会导入gettimehelloworld我写"G:\\code\\Python\\hello\\mymodule"mypath.pth. 可以放mypath.pth目录"G:\code\Python\hello"吗?

4

1 回答 1

1

不,它不会工作,根据site文档

路径配置文件是名称格式为 name.pth 的文件,并且存在于上述四个目录之一中。

“上面”提到的四个目录是特定于 Python 安装的,它们与工作目录无关。它实际上超过了四个(例如,它们不包括可选的用户站点包目录),但列表不是任意长的,并且工作目录从不参与确定.pth要使用的文件。

于 2017-09-07T03:12:39.307 回答