PATH环境变量 [英] PATH environment variable

查看:115
本文介绍了PATH环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

O / S:Win2K

Vsn of Python:2.4

基于对该组中其他帖子的搜索,它看起来好像是

os.environ [''PATH'']是获取PATH环境变量的一种方法。


我的问题:

1 os.environ [''PATH'']包含PATH环境

变量是否正确?

2)是否有其他方法可以获取PATH环境变量?如果是这样的话,

是获取PATH环境变量的另一种方式,比另一种方式更好吗?

解决方案

mi ************ @ yahoo。 com 写道:

根据对该组中其他帖子的搜索,好像
os.environ [''PATH'']是一个获取PATH环境变量的方法。

我的问题:
1)os.environ [''PATH'']包含PATH环境变量是否正确?


是的。

2)是否有其他方法可以获取PATH环境变量?如果是这样,
是获取PATH环境变量的一种方式,而不是另一种方式?




no。使用environ变量是阅读环境的首选方式

变量。


< / F>


mi************@yahoo.com 写道:

基于对该组中其他帖子的搜索,似乎
os.environ [''PATH'']是单向的获取PATH环境变量。

我的问题:
1)os.environ [''PATH'']包含PATH环境变量是否正确?


是的。

2)是否有其他方法可以获取PATH环境变量?如果是这样,
是获取PATH环境变量的一种方式,而不是另一种方式?




no。使用environ变量是阅读环境的首选方式

变量。


< / F>


mi************@yahoo.com 写道:

O / S:Win2K
Python的Vsn:2.4

基于搜索该组中的其他帖子,它显示为虽然os.environ [''PATH'']是获取PATH环境变量的一种方法。

我的问题:
1)os.environ是否正确[ ''PATH'']包含PATH环境变量?
2)是否有其他方法可以获取PATH环境变量?如果是这样,
是获取PATH环境变量的一种方式,而不是另一种方式?




这是最好的方法,因为它便携式。如果你没有

os.environ,你可能可以获得PATH但是读取一些

子流程的输出,例如:


导入命令

path = commands.getoutput(''echo


O/S: Win2K
Vsn of Python:2.4

Based on a search of other posts in this group, it appears as though
os.environ[''PATH''] is one way to obtain the PATH environment variable.

My questions:
1) is it correct that os.environ[''PATH''] contains the PATH environment
variable?
2) are there other ways to obtain the PATH environment variable? if so,
is one way of obtaining the PATH environment variable preferable to
another way?

解决方案

mi************@yahoo.com wrote:

Based on a search of other posts in this group, it appears as though
os.environ[''PATH''] is one way to obtain the PATH environment variable.

My questions:
1) is it correct that os.environ[''PATH''] contains the PATH environment
variable?
yes.
2) are there other ways to obtain the PATH environment variable? if so,
is one way of obtaining the PATH environment variable preferable to
another way?



no. using the environ variable is the preferred way to read environment
variables.

</F>


mi************@yahoo.com wrote:

Based on a search of other posts in this group, it appears as though
os.environ[''PATH''] is one way to obtain the PATH environment variable.

My questions:
1) is it correct that os.environ[''PATH''] contains the PATH environment
variable?
yes.
2) are there other ways to obtain the PATH environment variable? if so,
is one way of obtaining the PATH environment variable preferable to
another way?



no. using the environ variable is the preferred way to read environment
variables.

</F>


mi************@yahoo.com wrote:

O/S: Win2K
Vsn of Python:2.4

Based on a search of other posts in this group, it appears as though
os.environ[''PATH''] is one way to obtain the PATH environment variable.

My questions:
1) is it correct that os.environ[''PATH''] contains the PATH environment
variable?
2) are there other ways to obtain the PATH environment variable? if so,
is one way of obtaining the PATH environment variable preferable to
another way?



That''s the best way because it''s portable. If you didn''t have
os.environ, you might be able to get PATH but reading the output of some
subprocess, e.g:

import commands
path = commands.getoutput(''echo


这篇关于PATH环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆