user87901
0
Q:

get diroctary in python

import os

path = os.getcwd()

print(path)
# /Users/mbp/Documents/my-project/python-snippets/notebook

print(type(path))
# <class 'str'>
21
import os
cwd = os.getcwd()
2
import os
cwd = os.getcwd()
print(cwd)
5
import os

#Get Current working Directory
currentDirectory = os.getcwd()

#Change the Current working Directory
os.chdir('/home/varun')
4

New to Communities?

Join the community