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, System Call Related
Python: Get Environment Variable
Python: Make System Call
Python: Get Command Line Args
Python: Compress/Decompress Gzip Files
Python: Get Image Size
Python
Search 🔍
Overview
Python 3
Python 2
Python 2 and 3 Difference
Source Code Encoding
Help
Print Version
Builtin Help
Comment
Comment
String
String
Unicode 🐍
Arithmetic
Operators
Assignment
Convert Int, Float, String
Complex Numbers
Boolean
True, False
Boolean Operators
Test Equality
Test Order
Conditional
If Else
Loop, Iteration
Loop
Data Structure
List
Dictionary
Tuple
Sets
Sequence Types
JSON
Function and Class
Function
Lambda
Closure
Decorator
Class
Object, ID, Type
Module
Import Module
Show Module Doc
List Module's Functions
List Modules
Module Search Paths
Write a Module
Misc
Datetime
Timing, Benchmark
Regex
Regex
Regex Reference
Read Write File
Read File
Write File
Walk Directory
File Path
Find Script Path
Unicode, Encoding
Get Unicode Name, Codepoint
Convert File Encoding
Text Processing
Find Replace in dir
Find Replace by Regex
Count Word Frequency
Web
Send Email
GET Web Page
Web Crawler
HTTP POST
Misc
Format Code
Get Env Var
System Call
Get Command Line Args
Decompress Gzip
Get Image Size
Transpose Matrix
Check Page Load Size
Thumbnail Generation