如何更改sys.path?

编程入门 行业动态 更新时间:2024-10-26 16:28:20
本文介绍了如何更改sys.path?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是sys.path中路径的python搜索模块吗? 如何手动更改它?

解决方案

Ju Hui写道:

是sys.path中路径的python搜索模块吗? sys.path是Python解释器搜索的路径列表 模块,是的。 如何更改它manuallly?

手动 ? - ) 你的意思是动态地,通过代码 ?如果是的话,它只是一个列表。您可以像对待任何其他列表一样修改它。 否则,您可能需要查看PYTHON_PATH环境变量。 /> - bruno desthuilliers python -c" print''@''。join([''。''' .join([w [:: - 1] for p in p.split(''。'')])for p in''o****@xiludom.gro''。 split(''@'')])"

是的,我的意思是我要更改sys.path值并将其保存到下一个 使用。 我可以更改sys.path的值,但我不能保存它是永久性的。 我的电脑上没有python_path环境,它与sys.path之间的关系是什么?

Ju Hui写道:

是的,我的意思是我要更改sys.path值并将其保存到下一个使用。我可以更改sys.path的值,但我不能保存永久。我的电脑上没有python_path环境,它和sys.path之间的关系是什么?

在Windows中,至少,您可以创建PYTHONPATH变量并为其分配 ,这是您希望Python在运行脚本时检查的目录的路径。

is python search module by paths in sys.path? how to change it manuallly?

解决方案

Ju Hui wrote:

is python search module by paths in sys.path? sys.path is the list of path where the Python interpreter will search modules, yes. how to change it manuallly?

"manually" ?-) You mean "dynamically, by code" ? If yes, it''s just a list. You can modify it like you''d do for any other list. Else, you may want to look at the PYTHON_PATH environnement variable. -- bruno desthuilliers python -c "print ''@''.join([''.''.join([w[::-1] for w in p.split(''.'')]) for p in ''o****@xiludom.gro''.split(''@'')])"

yes, I mean I want change the sys.path value and save it for next using. I can change the value of sys.path, but I can''t "save" it permanently. There is no python_path environment on my pc, what the relationship between it and the sys.path?

Ju Hui wrote:

yes, I mean I want change the sys.path value and save it for next using. I can change the value of sys.path, but I can''t "save" it permanently. There is no python_path environment on my pc, what the relationship between it and the sys.path?

In Windows, at least, you can create the PYTHONPATH variable and assign to it the paths of the directories you want Python to check for when running a script.

更多推荐

如何更改sys.path?

本文发布于:2023-11-23 21:16:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622883.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何更改   sys   path

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!