擅长:python、mysql、java
<p><strong>对于Python 3.x(按指定):</strong></p>
<p>问题是来自<code>input()</code>的键盘输入是<code>str</code>(字符串)类型,它不是数字类型(即使用户键入数字)。但是,这很容易通过更改输入行来解决,例如:</p>
<pre><code>weight = float(input("How much do you weigh (in pounds)?"))
</code></pre>
<p>以及</p>
<pre><code>height = float(input("What is your height (in inches)?"))
</code></pre>
<p>从而将<code>input()</code>的字符串输出转换为数值型<code>float</code>。</p>