Is it possible to set an environment variable from Python permanently?

后端 未结 2 1984
既然无缘
既然无缘 2020-12-10 04:23

Using os module I can get the values of the environment variables. For example:

os.environ[\'HOME\']

However, I cannot set the

2条回答
  •  伪装坚强ぢ
    2020-12-10 04:58

    I am not sure. You can return the variable and set it that way. To do this print it.

    (python program)

    ...
    print foo
    

    (bash)

    set -- $(python test.py)
    foo=$1
    

提交回复
热议问题