擅长:python、mysql、java
<p>您只在您的<code>else</code>中重新调用<code>main</code>。您可以重新考虑如下因素:</p>
<pre><code>def main():
txt1 = input("Please enter value only 2 \n")
if txt1 == 2:
print txt
print txt1
time.sleep(3)
main()
</code></pre>
<p>或者,只需调用<code>main()</code>(而不是将其包装在<code>while</code>循环中)并将循环移到内部。我也会显式传递<code>txt</code>,而不是依赖范围:</p>
^{pr2}$
<p>后者避免了递归问题。在</p>