python使用os库临时改变环境变量

 s=os.getcwd()                                                #获取当前文件的位置如 'C:\\Users\\Administrator\\Desktop\\TEXT'
 s=os.path.split(s)[0]                                       #去掉末尾\\后面的内容,变成 'C:\\Users\\Administrator\\Desktop'
 s=s+'\\Mozilla Firefox'                                    #变成 'C:\\Users\\Administrator\\Desktop\\Mozilla Firefox'
 os.environ['Path']=os.environ['Path']+s         #在环境变量中Path后添加字符串s

猜你喜欢

转载自blog.csdn.net/weixin_38603360/article/details/81265046
今日推荐