擅长:python、mysql、java
<p>不要使用递归来解决这个问题,应该使用<code>while</code>循环。另外,不需要您的<code>x</code>参数。在</p>
<pre><code>def setVarInt():
while True:
try:
return int(input())
except ValueError:
print('Please enter an integer')
</code></pre>
<p>然后当你调用这个函数时,你必须捕捉返回值以便打印它。在</p>
^{pr2}$