下面的代码通过匹配不同的模式从文本中提取两个字符串
def urlChange(self, event):
text = self.txtUrl.GetValue()
matches = re.findall('GET (\S+).*Host: (\S+).*Cookie: (.+\S)\s*', text, re.DOTALL or re.MULTILINE)
if matches:
groups = matches[0]
self.txtUrl.SetValue(groups[1] + groups[0])
self.txtCookie.SetValue(groups[2])
else:
matches = re.findall('GET (\S+).*Host: (\S+).*', text, re.DOTALL or re.MULTILINE)
if matches:
groups = matches[0]
self.txtUrl.SetValue(groups[1] + groups[0])
self.txtCookie.Clear()
else:
matches = re.findall('.*(http://\S+)', text, re.DOTALL or re.MULTILINE)
if matches:
self.txtUrl.SetValue(matches[0])
matches = re.findall('.*Cookie: (.+\S)', text, re.DOTALL or re.MULTILINE)
if matches:
self.txtCookie.SetValue(matches[0])
只有当最后一条re.findall('.*(http://\S+)'...
语句运行时,我才会收到以下错误消息:
Traceback (most recent call last):
File "./curl-gui.py", line 105, in urlChange
text = self.txtUrl.GetValue()
RuntimeError: maximum recursion depth exceeded
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.6/dist-packages/apport_python_hook.py", line 48, in apport_excepthook
if not enabled():
File "/usr/lib/python2.6/dist-packages/apport_python_hook.py", line 21, in enabled
import re
RuntimeError: maximum recursion depth exceeded while calling a Python object
Original exception was:
Traceback (most recent call last):
File "./curl-gui.py", line 105, in urlChange
text = self.txtUrl.GetValue()
RuntimeError: maximum recursion depth exceeded
目前没有回答
相关问题 更多 >
编程相关推荐