1.匹配对应的字符串:

 

import re

pattern = [re.compile(r'.+/\d_\d\.png$'),
re.compile(r'.+/\d\.\d\.png$'),
re.compile(r'.+/\d\.jpg'),
re.compile(r'.+/\d-\d\.jpg'),
re.compile(r'.+/\d\.\d\.png$')]

file = 'a/1_1.png'
if re.match(pattern[0], file):
print

 

黄世宇/Shiyu Huang's Personal Page:​​https://huangshiyu13.github.io/​