代码:
import re
m=re.match('zc','zcdd')
if m is not None:
print(m.group())
else:
print(m)
m=re.match('zc','ddzc')
if m is not None:
print(m.group())
else:
print(m)
m=re.search('zc','zcdd')
if m is not None:
print(m.group())
else:
print(m)
m=re.search('zc','ddzc')
if m is not None:
print(m.group())
else:
print(m)
m=re.findall('a','abacd')
print(m)
运行: