re正则匹配
import re #导入re a=re.findall("picture","picture what i find") #re模块 re.findall("匹配规则","匹配规则所在字符串") print(a) 1、^元字符:字符串开始位置与匹配规则符合就匹配,否则不匹配 import re #导入re a=re.findall("^picture","picture what i find") #re模块 re.findall("匹配规则","匹配规则所在字符串") print(a) ['picture'] ^元字符写到[]字符集里就是反取 import re #导入re a=re.findall("[^picture]","picture what i find") #re模块 re.findall("匹配规则","匹配规则所在字符串") print(a)[' ', 'w', 'h', 'a', ' ', ' ', 'f', 'n', 'd'] 2、$字符:字符串结束位置与匹配规则相匹配则匹配, $在匹配规则结尾 import re #导入re a=re.findall("picture$","this is the picture") #re模块 re.findall("匹配规则","匹配规则所在字符串") print(a) 3、*元字符: 需要字符串里完全符合,匹配规则