Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python open file location

#For accessing the file in the same folder
file_name = "same.txt"
read_file(file_name)

#For accessing the file in a folder contained in the current folder
file_name = os.path.join(file_dir, 'Folder1.1/same.txt')
read_file(file_name)

#For accessing the file in the parent folder of the current folder
file_name = os.path.join(file_dir, '../same.txt')
read_file(file_name)

#For accessing the file inside a sibling folder.
file_name = os.path.join(file_dir, '../Folder2/same.txt')
file_name = os.path.abspath(os.path.realpath(file_name))
print file_name
read_file(file_name)
Comment

PREVIOUS NEXT
Code Example
Python :: columnspan tkinter 
Python :: merge two arrays python 
Python :: class in python 
Python :: puthon for loop 
Python :: python compare dates 
Python :: if in one line python 
Python :: how to move the element of an array in python by one step 
Python :: Insert between Characters Python 
Python :: upload file django 
Python :: Amazon price tracker in Python 
Python :: df to dict 
Python :: geopandas read postgis SQL 
Python :: how to convert a matrix string back to a matrix python 
Python :: how to repeat a row in pandas 
Python :: django request.data example 
Python :: star program in python using for loop 
Python :: how to leave a function python 
Python :: open file in python 
Python :: change xlabel python 
Python :: django upload multiple files 
Python :: clipboard python 
Python :: random seed python 
Python :: pearsons correlation calculation 
Python :: python for loop range 
Python :: seaborn countplot hue stacked 
Python :: python secret 
Python :: filter field set in django formds 
Python :: how to start coding in python 
Python :: pandas python example 
Python :: phython to c converter 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =