Python字符串匹配----6種方法的使用

1. re.match 嘗試從字符串的起始位置匹配一個模式,若是不是起始位置匹配成功的話,match()就返回none。正則表達式 import re line="this hdr-biz 123 model server 456" pattern=r"123" matchObj = re.match( pattern, line) 2. re.search 掃描整個字符串並返回第一個成功的匹配
相關文章
相關標籤/搜索