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