擅长:python、mysql、java
<p>这只是一个拼写错误<code>Celsius</code>而不是<code>Celcius</code></p>
<p>这会奏效的</p>
<pre><code>def convertTemperature(T, unitFrom, unitTo):
if unitFrom=="Fahrenheit" and unitTo=="Celsius":
T=(T-32)/1.8
return T
elif unitFrom=="Kelvin" and unitTo=="Celsius":
T=T-273.15
return T
elif unitFrom=="Celsius" and unitTo=="Fahrenheit":
T=1.8*T+32
return T
elif unitFrom=="Kelvin" and unitTo=="Fahrenheit":
T=1.8*T-459.67
return T
elif unitFrom=="Celsius" and unitTo=="Kelvin":
T=T+273.15
return T
elif unitFrom=="Fahrenheit" and unitTo=="Kelvin":
T=(T*459.67)/1.8
return T
print(convertTemperature(50.0, "Fahrenheit", "Celsius"))
</code></pre>