Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get path to current directory python

import os
os.path.abspath(os.getcwd())
Comment

file path current directory python

#Python 3

#For the directory of the script being run:

import pathlib
pathlib.Path(__file__).parent.resolve()

#For the current working directory:

import pathlib
pathlib.Path().resolve()

#Python 2 and 3

#For the directory of the script being run:

import os
os.path.dirname(os.path.abspath(__file__))

#If you mean the current working directory:

import os
os.path.abspath(os.getcwd())
Comment

python get path of current file

import pathlib
pathlib.Path(__file__).parent.absolute()
Comment

python os get dir path

from os import getcwd # only import "getcwd" from os

getcwd() # Get the current working directory
Comment

PREVIOUS NEXT
Code Example
Python :: rearrange list 
Python :: procfile heroku django 
Python :: how to write a font in pygame 
Python :: neat python full form 
Python :: python tipi array 
Python :: how to print 69 in python 
Python :: json post python with headers 
Python :: pandas series to list 
Python :: python numpy reverse an array 
Python :: replacing values in pandas dataframe 
Python :: how to say hello with name in python 
Python :: get home directory in windows python os 
Python :: python argparse 
Python :: django clear db 
Python :: do you have to qualift for mosp twice? 
Python :: pythonic 
Python :: open administrator command prompt using python 
Python :: for loop with float python 
Python :: Feature importance Decision Tree 
Python :: Print a nested list line by line in python 
Python :: list to string python 
Python :: how do I run a python program on atom 
Python :: flask run on ip and port 
Python :: random element python 
Python :: how to change number of steps in tensorflow object detection api 
Python :: python boxplot legend 
Python :: turn of warning iin python 
Python :: dict to array of string python 
Python :: how to print something with tkinter 
Python :: argparse example python pyimagesearch 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =