OS module – The function in the os module does the operating system related task such as creating a directory, fetching contents, deleting the current directory, etc.
So to change the current working directory we use os module in python.
With os module we use chdir() function to change the directory.
import os os.chdir("path of the new directory")
We have changed the directory but for confirming it we can use getcwd() function.
import os os.chdir("path of new directory") a=os.getcwd() print(a)
In this way we can change the directory in python just by using chdir() function.