码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2019-07-16 00:16:24      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:int   取值   pos   data   class   左右   ali   datalist   amp   

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)

  

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

标签:int   取值   pos   data   class   左右   ali   datalist   amp   

原文地址:https://www.cnblogs.com/tallme/p/11192254.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!