Change the working directory in Python

Check: Get the current Directory in Python

Python – Changing the current working directory:

This will be achieved via the “os” module:

os.chdir(path)

Change the current working directory to path.

Code:

import os

print(os.getcwd())

os.chdir('C:\\\\Users\\\\user-x\\\\Desktop')

print(os.getcwd())

Bilel-A

Enthusiastic Network Engineer specializing in Cisco ACI, passionate about solving challenges. A lifelong learner who loves gaining and sharing knowledge. Profile: https://www.linkedin.com/in/bilel-ameur-71116b2b5
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x