Answers for "python file path current directory"

24

get wd in python

import os

path = os.getcwd()

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

print(type(path))
# <class 'str'>
Posted by: Guest on January-26-2020
11

python get current file location

import os
os.path.dirname(os.path.abspath(__file__))
Posted by: Guest on May-11-2020
2

python get dir

import os 
#full path
dir_path = os.path.dirname(os.path.realpath(__file__))

#current dir
cwd = os.getcwd()
Posted by: Guest on December-25-2020

Code answers related to "python file path current directory"

Python Answers by Framework

Browse Popular Code Answers by Language