1import os
2
3path = os.getcwd()
4
5print(path)
6# /Users/mbp/Documents/my-project/python-snippets/notebook
7
8print(type(path))
9# <class 'str'>
10
1import os
2
3abspath = os.path.abspath(__file__)
4dname = os.path.dirname(abspath)
5os.chdir(dname)
1import os
2cdir = os.getcwd() # it will return current working directory
3print("Previous_dir",cdir)
4# Previous_dir C:\Users\..\Desktop\python
5os.chdir('C:/Users/../Desktop/desire_folder') #chdir used for change direcotry
6print("Current_dir",cdir)
7# Current_dir C:\Users\..\Desktop\python\teamspirit