Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

remove extension from filename python

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

python delete file with extension

import os

dir_name = "/Users/ben/downloads/"
test = os.listdir(dir_name)

for item in test:
    if item.endswith(".zip"):
        os.remove(os.path.join(dir_name, item))
Comment

python code to remove file extension

import os
print os.path.splitext("sample.txt")[0]
Comment

PREVIOUS NEXT
Code Example
Python :: hotkey python 
Python :: gnome-shell turn off 
Python :: flask mail 
Python :: rsplit string from last 
Python :: datetime year python 
Python :: how to only print final iteration of a for loop pyhton 
Python :: calculate vif in python 
Python :: how to find no of times a elements in list python 
Python :: count values pandas 
Python :: python __gt__ 
Python :: set cookie in python requests 
Python :: np.array average row 
Python :: generate random number python 
Python :: json.dumps no spaces 
Python :: check if is the last element in list python 
Python :: how to veiw and edit files with python 
Python :: python 2.7 check if variable is none 
Python :: how to create requirements.txt django 
Python :: webbrowser.google.open python 
Python :: array length godot 
Python :: errno 13 permission denied python 
Python :: selenium assert text on page python 
Python :: remove empty lines from file python 
Python :: python get number of days 
Python :: how to smooth a function in python 
Python :: django rest framework 
Python :: tuple slicing in python 
Python :: how to check if a letter is lowercase in python 
Python :: kfold cross validation sklearn 
Python :: Adding new column to existing DataFrame in Pandas by assigning a list 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =