def foo():
try:
html = get(url)
while (html is nogood):
foo()
return html
except Exception as e:
changeip()
foo()
函数
foo
返回纯文本的良好HTML内容。但是,当捕获到
Exception
时,该函数有时会返回None
。因此,我将最后一行更改为
return foo()
,并按预期工作。问题是为什么?在捕获中,它只是再次调用
foo
,最终会返回良好的HTML文本,为什么我要加上额外的return
?谢谢。