python正则表达式一:match、search和findall
发布日期:2021-05-15 18:27:38 浏览次数:12 分类:精选文章

本文共 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������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

上一篇:python正则表达式二:literal、re1|re2 和 .
下一篇:python聊天程序(socket+多线程)

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2025年04月24日 19时54分17秒