Python3-正则表达式~pattern.finditer

import re

pattern = re.compile(r'\d+\.\d*')
s = pattern.finditer("3.241592653 PI 100 10001.11 3.")
print(s)#返回一个对象 

for item in s:
    print(item)

 
  

/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 /Users/apple/PycharmProjects/stage4/spider/2018——0307/re_finditer.py

<_sre.SRE_Match object; span=(0, 11), match='3.241592653'>
<_sre.SRE_Match object; span=(19, 27), match='10001.11'>
<_sre.SRE_Match object; span=(28, 30), match='3.'>


Process finished with exit code 0

你可能感兴趣的:(正则表达式,Python3)