Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python get name of file

file_name = os.path.basename(file_path)
Comment

get name of a file in python

>>> f = open('/tmp/generic.png','r')
>>> f.name
'/tmp/generic.png'
>>> import os
>>> os.path.basename(f.name)
'generic.png'
Comment

python find file name

filesName = list(map(os.path.basename, glob.glob("..yourPath*txt")))
print(filesName)
Comment

PREVIOUS NEXT
Code Example
Python :: python pip jupyter notebook install 
Python :: python hide details 
Python :: NumPy unique Example Get the counts of each unique value 
Python :: how to send file in django response 
Python :: isolate row based on index pandas 
Python :: formatted string python 
Python :: copy directory from one location to another python 
Python :: library for converting text into image in python 
Python :: como transformar texto a audio y reproducirlo en pyrthon 
Python :: run streamlit from python 
Python :: convert list of list to list python 
Python :: how to get the current line number in python 
Python :: python round down 
Python :: tkinter how to remove button boder 
Python :: python 3 replace all whitespace characters 
Python :: pandas index between time 
Python :: docker django development and production 
Python :: pandas two dataframes equal 
Python :: click ok on alert box selenium webdriver python 
Python :: ms access python dataframe 
Python :: correlation between images python 
Python :: python pathlib create directory if not exists 
Python :: string to dictionary python 
Python :: input python 
Python :: box plot seaborn python 
Python :: unique_together what is used of it in django 
Python :: python add one 
Python :: Example of lambda function in python with list 
Python :: how to generate random numbers in python 
Python :: random torch tensor 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =