How to know/change current directory in Python shell?

PythonServer Side ProgrammingProgramming

You can change directory or cd in Python using the os module. It takes as input the relative/absolute path of the directory you want to switch to.

For example

>>> import os
>>> os.chdir('my_folder')

To know the current working directory or pwd use the os module.

For example

>>> import os
>>> print(os.getcwd())
Updated on 16-Dec-2019 06:09:54