import os
cdir = os.getcwd() # it will return current working directory
print("Previous_dir",cdir)
# Previous_dir C:Users..Desktoppython
os.chdir('C:/Users/../Desktop/desire_folder') #chdir used for change direcotry
print("Current_dir",cdir)
# Current_dir C:Users..Desktoppython eamspirit
import os
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# If by "current working directory" you mean
# the directory in which is saved the script in execution, then:
import os
cwd = os.path.dirname(os.path.realpath(__file__))
print(cwd)
import pathlib
print(pathlib.Path(__file__).parent.absolute())
import inspect
import os
module_path = inspect.getfile(inspect.currentframe())
module_dir = os.path.realpath(os.path.dirname(module_path))
os.chdir(module_dir)