Python 正则表达式返回真/假 [英] Python regular expressions return true/false

查看:53
本文介绍了Python 正则表达式返回真/假的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Python 正则表达式如何获得 True/False 返回?所有 Python 返回的是:

Using Python regular expressions how can you get a True/False returned? All Python returns is:

<_sre.SRE_Match object at ...>

推荐答案

Match 对象始终为真,如果不匹配则返回 None.只测试真实性.

Match objects are always true, and None is returned if there is no match. Just test for trueness.

if re.match(...):

这篇关于Python 正则表达式返回真/假的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆