How to get environment variables in Python

silencement
Release: 2019-05-25 15:51:48
Original
5922 people have browsed it

How to get environment variables in Python

Method 1 os reading

os reads directly and uses os to obtain the environment variable dictionary

How to get environment variables in Python

Print All environment variables, traverse the dictionary

How to get environment variables in Python

Method 2 pyhocon reading

pyhocon is a python configuration management library

pyhocon One of its functions is that it can be directly referenced using ${} in the configuration file. When pyhocon parses, it will automatically implement the above resolveEnv logic, corresponding to the environment variable.

The official website is as follows:https://github.com/chimpler/pyhocon

The configuration file is as follows:

default.conf

How to get environment variables in Python

${HOME} will automatically obtain the HOME in the environment variable when parsing and using parsing

How to use

How to get environment variables in Python

The above is the detailed content of How to get environment variables in Python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!