import re
pattern=r'\d\.\d+' #限定符,\d 0-9数字出现1次或多次
s='I study python3.11 every day Python2.7 I love you' #待匹配字符串
match=re.search(pattern,s)
s2='4.10python I study every day'
match2=re.search(pattern,s2)
s3='python I study every day'
match3=re.search(pattern,s3)
print(match)
print(match2)
print(match3)
print('匹配的数据',match.group())
print('匹配的数据',match2.group())
(仅供参考)
Comments NOTHING