# -*- coding: utf-8 -*- # @Time : 2022/8/9 21:24 # @Author : wangzhenjia # @Email : 13436409644@163.com # @File : hello.py import os import re path = os.getcwd() listdir = os.listdir(path) for x in listdir: match = re.match(r"1(.*)", x) try: match.group() print("匹配成功删除了1的文件") os.remove(match.group()) except: print("没有匹配成功")