© 1999-2048 dssz.net 粤ICP备11031372号
[其它] Python模块学习 re 正则表达式
说明:re.match re.match 尝试从字符串的开始匹配一个模式,如:下面的例子匹配第一个单词。 复制代码 代码如下: import re text = “JGood is a handsome boy, he is cool, clever, and so on…” m = re.match(r”(\w+)\s”, text) if m: print m.group(0), ‘\n’, m.group(1) else: print ‘not match’ re.match的函数原型为:<weixin_38688403> 上传 | 大小:44kb