Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python get name of file

file_name = os.path.basename(file_path)
Comment

get the name of a file using os

>>> list_of_names_in_directory = os.listdir('path/of/directory')
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

how to get file name use python3

file_name = os.path.basename("file_path")
Comment

PREVIOUS NEXT
Code Example
Python :: how to create a python venv 
Python :: count items in list 
Python :: psyche asteroid 
Python :: install qt designer python ubuntu 
Python :: python type hint for a string 
Python :: python - show repeted values in a column 
Python :: django dumpdata 
Python :: extract text regex python 
Python :: python inline conditional 
Python :: instagram private account hacking code python 
Python :: python- find multiple values in a column 
Python :: if in lambda function python 
Python :: python find closest value in list 
Python :: pandas to excel add another sheet in existing excel file 
Python :: how to separate a string or int with comma in python 
Python :: python os filename without extension 
Python :: map function using lambda in python 
Python :: pyspark datetime add hours 
Python :: python cmath constants 
Python :: scikit learn k means 
Python :: check if is the last element in list python 
Python :: screen size python 
Python :: how to remove blank lines from string in python 
Python :: django create token for user 
Python :: python run system command 
Python :: how to read a text file from url in python 
Python :: python json open file 
Python :: python csv 
Python :: install pip with pacman linux 
Python :: read csv without header pandas 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =