Python - Environment variable

> Procedural Languages > Python

Table of Contents

1 - Management

1.1 - Get

import os
print(os.environ) # all
print(os.environ['HOME']) # one with the array
print(os.environ.get("SOME_PARAMETER", "default_value")) # One with the get function

1.2 - Set

import os
os.environ["ENV_NAME"] = "value"