阅读背景:

python re.findall(rule,data),根据左右边界取值url中参数的值

来源:互联网 
import re

'''
取值postid,左边界"postid=",右边界"&"
'''
url="https://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)
import re

'''
取值postid,左边界"postid=",右边界"&a



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: