<div>
</div>
<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=="Celcius":
T=T-273.15
return T
elif unitFrom=="Celcius" 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=="Celcius" and unitTo=="Kelvin":
T=T+273.15
return T
elif unitFrom=="Fahrenheit" and unitTo=="Kelvin":
T=(T*459.67)/1.8
return T
</code></pre>
<p>unitFrom参数是当前温度,T是温度,unitTo是我要转换的温度。
我试着用<code>print(convertTemperature(50.0, "Fahrenheit", "Celcius"))</code>测试它,但结果是没有</p>