擅长:python、mysql、java
<pre><code>while i < length:
# ...
while number[i]==Type:
# ...
i+=1
</code></pre>
<p><code>i</code>在嵌套循环内递增,导致<code>number[i]</code>超出范围。你知道吗</p>
<p>一个简单而直接的解决方法是检查嵌套循环中<code>i</code>的值:</p>
<pre><code>while i < length:
# ...
while i < length and number[i]==Type:
# ...
i+=1
</code></pre>