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 absolute path from projectr 
Python :: Matplotlib rotated xticklabels 
Python :: create 8ball command in discord.py 
Python :: how to convert python input to int 
Python :: numpy random matrix 
Python :: time.strftime("%H:%M:%S") in python 
Python :: break all loops 
Python :: integer xticks 
Python :: plotting roc curve 
Python :: convert timedelta to days 
Python :: python async partial function 
Python :: python use functions from another file 
Python :: get request body flask 
Python :: django authenticate 
Python :: python numpy matrix to list 
Python :: how to save dataframe as csv in python 
Python :: looping through nested dictionary to nth 
Python :: pandas count values by column 
Python :: combination without repetition python 
Python :: replace word in column pandas lambda 
Python :: python tkinter entry hide text 
Python :: python zip() 
Python :: python while continue 
Python :: print random integers 
Python :: Read JSON files with automatic schema inference 
Python :: extract all text from website using beautifulsoup and python 
Python :: change index to dataframe pandas 
Python :: python positional argument follows keyword argument 
Python :: how to make variable global in python 
Python :: python absolute path 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =