Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to get just the filename in python

 import os
>>> base=os.path.basename('/root/dir/sub/file.ext')
>>> base
'file.ext'
>>> os.path.splitext(base)
('file', '.ext')
>>> os.path.splitext(base)[0]
'file'
Comment

PREVIOUS NEXT
Code Example
Python :: plt.savefig df.plot 
Python :: save fig plot dataframe 
Python :: python schedule timezone 
Python :: change size of selenium window 
Python :: python requests set user agent 
Python :: tkinter listbox delete all items 
Python :: python get list of all open windows 
Python :: how to check datatype of column in dataframe python 
Python :: selenium python enter text 
Python :: python mean and standard deviation of list 
Python :: add text to plot python 
Python :: python pip not working 
Python :: python initialize multidimensional list 
Python :: flask secret key generator 
Python :: random character generator python 
Python :: discord.py intents 
Python :: set axis title matplotlib 
Python :: python get human readable file size 
Python :: plot specific columns pandas 
Python :: np array n same values 
Python :: check if a list contains an item from another list python 
Python :: datetime not defined python 
Python :: discord.py unmute 
Python :: python randomise between 0 or 1 
Python :: distance euc of two arrays python 
Python :: pip install speedtest 
Python :: python copy file and rename 
Python :: how to get unix timestamp in python 
Python :: install wxpython 
Python :: python array delete last column 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =