2010-08-05 137 views
3

我的pythonpath存储在哪里? 当我写PYTHONPATH存储位置

import sys 
sys.path 

python从哪里得到这些数据?

+0

你想知道它的存储位置的原因吗?如果你想让python使用不同的pythonpath,你可以设置环境变量:PYTHONPATH。 – 2010-08-05 11:53:38

回答

2

Python从sys模块的路径属性获取该数据。此路径为list,如果您要将新目录添加到路径中,请使用append方法。

例如,该目录/home/me/mypy添加到路径,只是做:

import sys 
sys.path.append("/home/me/mypy")