import re
re_str = "hello this is python 2.7.13 and python 3.4.5"
pattern = "python [0-9].[0-9].[0-9]"
re.findall() 用来输出所有符合模式匹配的子串
res = re.findall(pattern=pattern,string=re_str)
print(res)
输出结果
['python 2.7.1', 'python 3.4.5']
设置标志flags=re.IGNORECASE,意思为忽略大小写
res = re.findall(pattern=pattern,string=re_str,flags=re.IGNORECASE)
还在更新中...