Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get directory of file python

import os 
dir_path = os.path.dirname(os.path.realpath(__file__))
Comment

python get dir

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

#current dir
cwd = os.getcwd()
Comment

python how to get directory of script

import os
print(os.path.abspath(''))
Comment

python os get dir path

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

getcwd() # Get the current working directory
Comment

python get dir from path

import os
your_file_path = "D:yourdirpathfile.csv"
print(f"Dir:{os.path.dirname(your_file_path)}") 
#>>> Dir:D:yourdirpath
Comment

python find dir

import os.path
from os import path

def main():

	print ("Is it File?" + str(path.isfile('guru99.txt')))
	print ("Is it File?" + str(path.isfile('myDirectory')))
if __name__== "__main__":
	main()
Comment

PREVIOUS NEXT
Code Example
Python :: get next multiple of a number 
Python :: pandas convert date to string 
Python :: plt plot circle 
Python :: round to two decimal places python 
Python :: plt.clear 
Python :: how to plot two columns graphs in python 
Python :: tkinter labelframe 
Python :: brownie normalize to wei 
Python :: how to get variable from setings django 
Python :: fraction thesis 
Python :: python get webpage source 
Python :: pandas remove index column when saving to csv 
Python :: django import model from another app 
Python :: select DF columns python 
Python :: required validator python WTForms 
Python :: seaborn increace figure size 
Python :: python import all words 
Python :: custom 404 page flask 
Python :: pandas index to list 
Python :: how to clear the console python 
Python :: how to get data from json web api in python 
Python :: pandas set font size plot 
Python :: get request python 
Python :: python plot two lines on same graph 
Python :: python merge strings in columns 
Python :: no limit row pandas 
Python :: require http method django view 
Python :: how to check sklearn version 
Python :: calculator in one line in python 
Python :: how to open file explorer in python 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =