Using the glob module:
import glob, os for f in glob.glob("P*.jpg"): os.remove(f)
Alternatively, using pathlib:
from pathlib import Path for p in Path(".").glob("P*.jpg"): p.unlink()
More Related Contents:
- I have a list of file names and I need to be able to count how many of the same file gets repeated for each file name [closed]
- How to remove English words from a file containing Dari words?
- How do you change the size of figures drawn with Matplotlib?
- How to determine the encoding of text?
- Selecting with complex criteria from pandas.DataFrame
- How to load all modules in a folder?
- Matplotlib scatter plot with different text at each data point
- How does swapping of members in tuples (a,b)=(b,a) work internally?
- how to clear the screen in python [duplicate]
- How can I sandbox Python in pure Python?
- TypeError: a bytes-like object is required, not ‘str’ in python and CSV
- Can we have assignment in a condition?
- How can I specify working directory for popen
- TypeError: module.__init__() takes at most 2 arguments (3 given)
- os.path.dirname(__file__) returns empty
- Python Slice Assignment Memory Usage
- Python Error: io.UnsupportedOperation: fileno
- Python Opencv SolvePnP yields wrong translation vector
- lambda arguments unpack error
- How to convert string to byte array in Python
- All example concurrent.futures code is failing with “BrokenProcessPool”
- Max in a sliding window in NumPy array
- Build a wheel/egg and all dependencies for a python project
- Python How to use ExcelWriter to write into an existing worksheet
- how to convert monthly data to quarterly in pandas
- Python Pandas: remove entries based on the number of occurrences
- setting up environment in virtaulenv using python3 stuck on setuptools, pip, wheel
- Pathname too long to open?
- Ways to slice a string?
- Why were True and False changed to keywords in Python 3