@
pattern = re.compile(r'\d+')    
m = pattern.match('6e812738712aaadad13')   
m.groups()
#findall是常用的,0,10分别表示的是开始匹配和,count
pattern = re.compile(r'\d+')   # 查找数字
result1 = pattern.findall('runoob 123 google 456')
result2 = pattern.findall('run88oob123google456', 0, 10)说明
常用的就是先定义一个pattern
然后写规则,注意要在字符串前写个r,防止转义
然后在pattern.findall(string) ,返回的是一个列表,就算只有一个匹配返回的也是列表
个人博客网站
个人GitHub地址
个人公众号:
原文:https://www.cnblogs.com/simon-idea/p/11398724.html