. Advertisement .
..3..
. Advertisement .
..4..
This article is a tutorial on how to remove extension filename in Python. Please leave your samples in the answer section below.
import os
folder_name = "/Users/ben/downloads/"
file_name = os.listdir(folder_name)
for item in file_name:
if item.endswith(".rar"):
os.remove(os.path.join(folder_name, item))
You can try this way
Check out this code. It works well for me
This is my approach