擅长:python、mysql、java
<p><code>input</code>返回一个字符串。有关<code>input</code>函数,请参见<a href="https://docs.python.org/3.5/library/functions.html#input" rel="nofollow">the docs</a>。将此函数的结果强制转换为字符串不会起任何作用。你知道吗</p>
<p>可以使用<a href="https://docs.python.org/3/library/stdtypes.html#str.isdecimal" rel="nofollow">^{<cd3>}</a>检查字符串是否为数字。你知道吗</p>
<pre><code>if user_input.isdecimal():
print("Strings only!")
</code></pre>
<p>这与您现有的<code>else</code>子句非常吻合。你知道吗</p>