如下例子:
#python 3.6
#蔡军生
#/caimouse/article/details/51749579
#
import re
text = 'This is some text -- with punctuation.'
pattern = 'is'
print('Text :', text)
print('Pattern:', pattern)
m = (pattern, text)
print('Match :', m)
s = (pattern, text)
print('Search :', s)
print('*' * 80)
text = 'is test'
m = (pattern, text)
print('Match :', m)
结果输出如下:
Text : This is some text -- with punctuation.
Pattern: is
Match : None
Search : <_sre.SRE_Match object; span=(2, 4), match='is'>
********************************************************************************
Match : <_sre.SRE_Match object; span=(0, 2), match='is'>
深入浅出Numpy
/course/detail/6149
Python游戏开发入门
/course/detail/5690
你也能动手修改C编译器
/course/detail/5582