一个正则表达式匹配

前端之家收集整理的这篇文章主要介绍了一个正则表达式匹配前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

http://alexliyu.blog.163.com/blog/static/1627544962011101710824160/


#-*- coding:utf-8 -*-

import urllib2 import urllib import re,time import cookielib import hashlib import base64 import os import random text = 'sinaSSOController.preloginCallBack({"retcode":0,"servertime":1359647780,"pcid":"gz-77611738e3891e38ba8aaafe340459214841","nonce":"FCLUR1","exectime":1})' print('text = ' + text) try: #serverdata = re.findall('{"retcode":0,"servertime":(.+?),"nonce":"(.+?)"}',response.read(),re.I)[0] # serverdata = re.findall('{"retcode":0,"servertime":(.*?),"nonce":"(.*?)"}',re.I)[0] serverdata = re.findall('{"retcode":0,.*"nonce":"(.*?)".*}',text)[0] print serverdata[0] print serverdata[1] except: print("ffffff") 原文链接:https://www.f2er.com/regex/363206.html

猜你在找的正则表达式相关文章