擅长:python、mysql、java
<p>您首先需要将总数%1乘以100,得到美分的值,单位是美分。你知道吗</p>
<pre><code>cents = math.ceil(total%1 * 100) ## for 32792039464.8 cents will be 0.8. times 100 is 80.
total = math.floor(total - cents/100) ## round the number down
print("You've got", total, "euro and ", cents, " cents.")
</code></pre>
<p>你也可以用这个:</p>
<pre><code>cents = round(total%1 * 100) ## for 32792039464.8 cents will be 0.8. times 100 is 80 cents.
total = round(total - cents/100) ## round the total down. 32792039464.8 to 32792039464
print("You've got", total, "euro and ", cents, " cents")
</code></pre>