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

PREVIOUS NEXT
Code Example
Python :: spammer bot python 
Python :: how to check in which directory python in running 
Python :: how to strip quotation marks in python 
Python :: pandas plotly backend 
Python :: how to add a image in tkinter 
Python :: how to check if left mousebuttondown in pygame 
Python :: install pytorch 
Python :: check numpy version 
Python :: how to make my jupyter prin full array 
Python :: matplotlib clear plot 
Python :: Drop Rows by Index in dataframe 
Python :: plt vertical line 
Python :: Update all packages using pip on Windows 
Python :: python selenium run javascript 
Python :: pandas percent change 
Python :: put comma in numbers python 
Python :: verificar se arquivo existe python 
Python :: how to add icon to tkinter window 
Python :: tkinter entry default value 
Python :: count number of islands python 
Python :: convert pdf to base64 python 
Python :: import reverse_lazy 
Python :: remove punctuation from string python 
Python :: comment dériver une classe python 
Python :: extract float from string python 
Python :: matoplotlib set white background 
Python :: complex phase python 
Python :: how to loop in python 
Python :: Install requests-html library in python 
Python :: python copy file and rename 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =