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


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)

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM