IT虾米网

python设置进程的环境变量

developer 2018年06月24日 编程语言 1128 0
import os 
print 'setenv...', 
print os.environ['USER']                 # show current shell variable value 
 
os.environ['USER'] = 'Brian'             # runs os.putenv behind the scenes 
os.system('python echoenv.py') 
 
os.environ['USER'] = 'Arthur'            # changes passed to spawned programs 
os.system('python echoenv.py')           # and linked-in C library modules 
 
os.environ['USER'] = raw_input('?')     
print os.popen('python echoenv.py').read() 

评论关闭
IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!