
本文共 1708 字,大约阅读时间需要 5 分钟。
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
1. match���search���������
Match���������������������������������������������������������������������������������������������������������None���������������������������������������������������������������������������
Search���������������������������������������������������������������������������������������������������������������������None���������������������������������������������������������������
2. findall���������
findall���������������������������������������������������������������������������������������������������������������������������������������������������������������������������
3. ������������
������������������������������Python������������������������
import re# match������������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)# search������������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)# findall������������print(re.findall('a', 'abacd'))
4. ������������
������������������������������������������
zdcdNonezdNonea['a', 'b', 'a', 'd']
5. ������
������match���search���findall������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
