How to access environment variable values?

后端 未结 12 1353
孤独总比滥情好
孤独总比滥情好 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:47

    You can also try this

    First, install python-decouple

    pip install python-decouple
    

    import it in your file

    from decouple import config
    

    Then get the env variable

    SECRET_KEY=config('SECRET_KEY')
    

    Read more about the python library here

提交回复
热议问题