擅长:python、mysql、java
<p>因为要分割整数,所以Python将结果表示为<code>float</code>,而不是<code>int</code>。要按照您的要求格式化<code>float</code>,您必须使用字符串格式:</p>
<pre><code>>>> print('{:g}'.format(3.14))
3.14
>>> print('{:g}'.format(3.0))
3
</code></pre>
<p>所以把它插入你的代码:</p>
<pre><code>print("Y = {:g}X - {}.".format(m, b))
</code></pre>