擅长:python、mysql、java
<p>首先,可以用for循环替换while循环</p>
<pre><code>for i in range(len(test_cases)):
print test_cases[i].indent
</code></pre>
<p>然而,在python中,循环索引并使用该索引访问元素通常是一种代码味道。最好只是在元素之间循环</p>
<pre><code>for test_case in test_cases:
print test_case.indent
</code></pre>