Obtenez WD dans Python
import os
path = os.getcwd()
print(path)
# /Users/mbp/Documents/my-project/python-snippets/notebook
print(type(path))
# <class 'str'>
Happy Hawk
import os
path = os.getcwd()
print(path)
# /Users/mbp/Documents/my-project/python-snippets/notebook
print(type(path))
# <class 'str'>
import os
cwd = os.getcwd()
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
import os
os.getcwd()
# print current working directory in python
import os
cwd = os.getcwd()
print(cwd)
# 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)