python如何提取字符串中的指定的内容?
比如有如下字符text=cssPath:"http://imgcache.qq.com/ptlogin/v4/style/32",sig:"OvL7F1OQEojtPkn...
比如有如下字符 text=cssPath:"http://imgcache.qq.com/ptlogin/v4/style/32",sig:"OvL7F1OQEojtPkn5x2xdj1*uYPm*H3mpaOf3rs2M",clientip:"82ee3af631dd6ffe",serverip:"",version:"201404010930"
怎么提取元素为sig的值?就是OvL7F1OQEojtPkn5x2xdj1*uYPm*H3mpaOf3rs2M; 展开
怎么提取元素为sig的值?就是OvL7F1OQEojtPkn5x2xdj1*uYPm*H3mpaOf3rs2M; 展开
展开全部
>>> s = 'text=cssPath:"http://imgcache.qq.com/ptlogin/v4/style/32",sig:"OvL7F1OQEojtPkn5x2xdj1*uYPm*H3mpaOf3rs2M",clientip:"82ee3af631dd6ffe",serverip:"",version:"201404010930"'
>>> import re
>>> res = re.findall(r'sig:"([^"]+)"',s)
>>> res
['OvL7F1OQEojtPkn5x2xdj1*uYPm*H3mpaOf3rs2M']
>>> res[0]
'OvL7F1OQEojtPkn5x2xdj1*uYPm*H3mpaOf3rs2M'
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询