标签:alt size pil object 忽略 height mat png 大小写
1. 基本使用:
|
输出
|
#re
#pattern = re.compile() #生成pattern对象
#pattern.match #pattern.search
#pattern.find str1 = "itest python"
pa = re.compile(r"itest")
#加r代表是原字符串,不加r容易将\n等进行转义。 print (type(pa)) print (help(pa)) print(pa.match(str1))
print(pa.match(str1).group())
print (pa.match(str1).span()) #获取原字符串 print (pa.match(str1).string) #获取实例 print (pa.match(str1).re) #忽略大小写
pa = re.compile(r"itest",re.I)
ma = pa.match("Itest python") print ("ma:", ma.group()) ma1 = pa.match("ITEST python") print("mal:", ma1.group()) ma2 = pa.match("itest python") print ("ma2:", ma2.group()) #groups
pa = re.compile(r"(itest)",re.I)
ma_group = pa.match("Itest python").group() print ("ma_group:", ma_group) ma_groups = pa.match("Itest python").groups()
print ("ma_groups:", ma_groups) |
<class ‘re.Pattern‘>
None
<re.Match object; span=(0, 5), match=‘itest‘> itest (0, 5) itest python re.compile(‘itest‘) ma: Itest
mal: ITEST ma2: itest ma_group: Itest
ma_groups: (‘Itest‘,) |
标签:alt size pil object 忽略 height mat png 大小写
原文地址:https://www.cnblogs.com/ting152/p/12810965.html