Python Module os: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 2: | Line 2: | ||
* https://docs.python.org/3/library/os.html#module-os | * https://docs.python.org/3/library/os.html#module-os | ||
=Internal= | =Internal= | ||
* [[Python Language | * [[Python Language#os|Python Language | Standard Library]] | ||
* [[Python_Module_shutil|shutil]] | * [[Python_Module_shutil|shutil]] | ||
Revision as of 01:32, 20 June 2022
External
Internal
Overview
Environment Variables
To get an environment variable:
import os
print(os.environ.get('HOME'))
If the environment variable does not exist, the call will get None
To set an environment variable:
import os
os.environ['MY_VAR'] = 'myvalue'
This works for testing.