import re ‘‘‘ 取值postid,左边界"postid=",右边界"&" ‘‘‘ url="http://wwww.baidu.com/aspx?postid=6232&actiontip=‘保存成功‘" postid=re.findall(r"postid=(.*?)&",url)[0] print(postid) def findall_data(data,LB="",RB=""): rule=LB + r"(.+?)" + RB datalist=re.findall(rule,data) return datalist data1=findall_data(url,"postid=",‘&‘)[0] print(data1)
原文地址:https://www.cnblogs.com/tallme/p/11192254.html
时间: 2024-10-05 02:19:19