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: Call shell command
Python: Get Command Line Args
Python: Compress Decompress Gzip File
Python: get image width height 📜
Python
Search 🔍
Help
Print Version
Builtin Help
Comment, Print
Comment
Print
Number
Number
String
String
Unicode
Arithmetic
Operators
Assignment
Convert Int Float String
Boolean
True, False
Boolean Operators
Test Equality
Test Order
Variable
Variable
Conditional
If Else
Loop, Iteration
Loop
Data Structure
List
Dictionary
Tuple
Sets
Sequence Types
JSON
Function and Class
Function
Class
Object, ID, Type
Module
Import Module
Regex
Regex
Read Write File
Read STDIN
Read File
Write File
Walk Directory
File Path
Find Script Path
Misc
Misc. Index