Python: Get Environment Variable

By Xah Lee. Date: . Last updated: .
# get environment variable

import os
print(os.getenv("HOME", "default value if none"))

# /Users/xah

Python

Overview

Help

String

Arithmetic

Boolean

Conditional

Loop, Iteration

Data Structure

Function and Class

Module

Misc

Regex

Text Processing

Web

Misc