Syntax error How can I do "cd" in Python?

How can I do "cd" in Python?



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')
Updated on: 2019-12-12T07:33:08+05:30

15K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements