这段文本
In [6]: re.findall("<!--.*-->",aa,re.S|re.M) #这样匹配的到
Out[6]: ['<!--\ngoogle_ad_client = "pub-7133395778201029";\ngoogle_ad_width = 468;\ngoogle_ad_height = 60;\ngoogle_ad_format = "468x60_as";\ngoogle_ad_type = "image";\ngoogle_ad_channel = "";\n//-->']
In [8]: re.sub("<!--.*-->","",aa,re.S|re.M) #这样替换不掉呢
Out[8]: '<!--\ngoogle_ad_client = "pub-7133395778201029";\ngoogle_ad_width = 468;\ngoogle_ad_height = 60;\ngoogle_ad_format = "468x60_as";\ngoogle_ad_type = "image";\ngoogle_ad_channel = "";\n//-->'
一直是这么写的没毛病 啊 为啥这次不行了呢
1
kcnscrew 2019-04-18 23:33:49 +08:00
def findall(pattern, string, flags=0)
def sub(pattern, repl, string, count=0, flags=0) |
2
GTim 2019-04-19 07:12:48 +08:00 via iPhone
大哥,参数顺序错了
|