How to access environment variable values?

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

    There's also a number of great libraries. Envs for example will allow you to parse objects out of your environment variables, which is rad. For example:

    from envs import env
    env('SECRET_KEY') # 'your_secret_key_here'
    env('SERVER_NAMES',var_type='list') #['your', 'list', 'here']
    

提交回复
热议问题