programming-examples/python/Basics/Access environment variables.py

10 lines
372 B
Python
Raw Normal View History

2019-11-18 14:44:36 +01:00
import os
# Access all environment variables
print('*----------------------------------*')
print(os.environ)
print('*----------------------------------*')
# Access a particular environment variable
print(os.environ['HOME'])
print('*----------------------------------*')
print(os.environ['PATH'])
print('*----------------------------------*')