Python Module os: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 3: Line 3:
=Internal=
=Internal=
* [[Python Language Modularization#json|Python Language Modularization]]
* [[Python Language Modularization#json|Python Language Modularization]]
* [[Python_Module_shutil|shutil]]


=Overview=
=Overview=

Revision as of 20:17, 2 March 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.

Working Directory

File Operations in Python | Working Directory