擅长:python、mysql、java
<p>有一点是在python中不需要main。另一种方法就是这样做。你知道吗</p>
<p>你真的需要一个主要的吗?你知道吗</p>
<pre><code>import os
def CalcAndDisplayShipping(weight):
UNDER_SIX = 1.1
TWO_TO_SIX = 2.2
SIX_TO_TEN = 3.7
OVER_TEN = 3.8
shipping = 0.0
if weight > 10:
shipping = weight * OVER_TEN
elif weight > 6:
shipping = weight * SIX_TO_TEN
elif weight > 2:
shipping = weight * TWO_TO_SIX
else:
shipping = weight * UNDER_SIX
print ("Shipping Charge: $", shipping)
weight = float(input("Enter package weight: "))
CalcAndDisplayShipping(weight)
</code></pre>