Quick Post: How to go up/down a directory structure using Python!

Subscribe to my newsletter and never miss my upcoming articles

Introduction

Introducing Quick Posts - Small posts containing useful tips and tricks! This is a series! These posts will not have a Subtitle or Cover photo

Content

So suppose, you're in a directory C:\Windows\system32 and want to go to C:\Windows, so how do you do that? Well, you can use os.chdir(), yeah! But how? Code below:

import os

print(os.getcwd())
os.chdir("..")
print("\n", os.getcwd())

Output Below:

C:\Windows\system32> python quick-post-1.py
C:\Windows\system32

C:\Windows

End

Thanks, for reading Quick Posts! More coming soooooooon! Stay Alert!

No Comments Yet