Python Tutorial
Python: Get Environment Variable
By Xah Lee. Date:
2014-02-03
. Last updated:
2019-03-22
.
#
get environment variable
import
os
print
(os.getenv(
"HOME"
,
"default value if none"
))
#
/Users/xah
Python
Search 🔍
Overview
Python 3
Python 2
Python 2 and 3 Difference
Python Source Code Encoding
Help
Print Version
Builtin Help
String
Quote String
String Escape
Unicode Escape
String Methods
Format String
Unicode 🐍
Arithmetic
Operators
Convert Int, Float, String
Complex Numbers
Boolean
True/False
Conditional
If Else
Loop, Iteration
Loop
Map f to List
Enumerate List
Loop Thru Dict
Data Structure
List
Copy Nested List
List Comprehension
List Methods
Sort
Dictionary
Dict Methods
Tuple
Sets
JSON
Function and Class
Function
Closure
2 Closure
Decorator
Class
Object, ID, Type
Module
List Modules
Write a Module
Misc
Datetime
Regex
Regex
Regex Reference
Text Processing
Read/Write File
Traverse Directory
File Path
Find Replace in dir
Find Replace by Regex
Get Unicode Name, Codepoint
Convert File Encoding
Count Word Frequency
Web
Send Email
GET Web Page
Web Crawler
HTTP POST
Misc
Find Script Path
Get Env Var
System Call
Decompress Gzip
Timing Function
Transpose Matrix
Check Page Load Size
Thumbnail Generation