Python面试题

当前位置: 面试问题网 > Python面试题 > Python里面search()和match()的区别

Python里面search()和match()的区别

match()函数只检测RE是不是在string的开始位置匹配, search()会扫描整个string查找匹配, 也就是说match()只有在0位置匹配成功的话才有返回,如果不是开始位置匹配成功的话,match()就返回none
   例如:
   print(re.match(‘super’, ‘superstition’).span())会返回(0, 5)
   而print(re.match(‘super’, ‘insuperable’))则返回None
   search()会扫描整个字符串并返回第一个成功的匹配
   例如:print(re.search(‘super’, ‘superstition’).span())返回(0, 5)
   print(re.search(‘super’, ‘insuperable’).span())返回(2, 7)

【Python里面search()和match()的区别】相关文章

1. Python里面search()和match()的区别

2. Python面试题:Python里面如何生成随机数

3. Python面试题:如何用Python来发送邮件

4. Python面试题:Python是如何进行内存管理的

5. Python里面如何拷贝一个对象

6. Python里面如何实现tuple和list的转换

7. 软件测试LoadRunner面试题:What is think time? How do you change the threshold?

8. C++:memset ,memcpy和strcpy的根本区别

9. JSP和EJB可以共享HttpSession么?EJB里面可以改变session里面的内容

10. 请写出一段Python代码实现删除一个list里面的重复元素

本文来源:https://www.mianshiwenti.com/a13493.html

点击展开全部

《Python里面search()和match()的区别》

将本文的Word文档下载到电脑,方便收藏和打印

推荐程度:

进入下载页面

﹝Python里面search()和match()的区别﹞相关内容

「Python里面search()和match()的区别」相关专题

其它栏目

也许您还喜欢