import re def is_matched(string): return True if re.match(r‘your regex‘,string) else False
如果匹配, re.match()会返回一个match对象
re.match()
<_sre.SRE_Match object; span=(0, 0), match=‘‘>
否则返回None
None
待续...
Python常用正则操作
原文:https://www.cnblogs.com/josephchuh/p/9238880.html