How to access environment variable values?

后端 未结 12 1337
孤独总比滥情好
孤独总比滥情好 2020-11-21 23:52

I set an environment variable that I want to access in my Python application. How do I get its value?

12条回答
  •  旧巷少年郎
    2020-11-22 00:39

    import os
    for a in os.environ:
        print('Var: ', a, 'Value: ', os.getenv(a))
    print("all done")
    

    That will print all of the environment variables along with their values.

提交回复
热议问题