擅长:python、mysql、java
<p>在这种情况下,您应该考虑使用默认值并只检查错误情况:</p>
<pre><code>response = "OK" # default value
for doc1,doc2 in itertools.izip(docs1, docs2):
if ... :
if ... :
response = "Error"
else... :
if ... :
response = "Error"
if response == "Error":
break
# If no errors were found, then the result must be OK
if response == "Error":
self.assert400(response, message="Bad request, empty body.")
else:
self.assert200(response, message="OK.")
</code></pre>
<p>这就使得只有一个错误就足以使整个事情失败。我有点不清楚你到底想做什么,所以做评论,如果这不是你所期望的。你知道吗</p>