Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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 :: django rest framework 
Python :: comparing two dataframe columns 
Python :: add hour minutes second python 
Python :: promote a row in panda dataframe to header 
Python :: completely uninstall python and all vritualenvs from mac 
Python :: python script header 
Python :: python list iterate in 1 line 
Python :: python getter decorator 
Python :: python how to get current line number 
Python :: python binary search algorithm 
Python :: how to do date time formatting with strftime in python 
Python :: find order of characters python 
Python :: python reverse array 
Python :: How many columns have null values present in them? in pandas 
Python :: natural log and log base 10 in python 
Python :: convert pdf folder to excell pandas 
Python :: django drop database postgres 
Python :: import django-on-heroku 
Python :: python remove first item in tuple 
Python :: numpy matrix 
Python :: django creating calculated fields in model 
Python :: how to draw a rectangle in pygame 
Python :: pip is not a batch command but python is installed 
Python :: collections counter 
Python :: how to write to the end of a file in python 
Python :: np deep copy matrix 
Python :: how to return an html file in flask 
Python :: python instagram downloader 
Python :: python pywhatkit 
Python :: how to install from url in python 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =