我将以下代码作为函数的一部分:
print("Is the fluid water/steam or R-134a: ")
fluid = input()
if fluid.casefold == "water":
hin = CP.PropsSI('H','P', pin,"T",lower_temp+zeroC, 'water')
hout = CP.PropsSI('H','P', pout,"T",upper_temp+zeroC, 'water')
return
elif fluid.casefold == "r134a" or fluid.casefold == "r-134a":
hin = CP.PropsSI('H','P', pin,"T",lower_temp+zeroC, 'R134a')
hout = CP.PropsSI('H','P', pout,"T",upper_temp+zeroC, 'R134a')
return
else:
print("Invalid Fluid")
params()
我的代码总是执行else语句,而不是if或elif语句。我是错误地使用了casefold,还是没有看到其他错误
答案 0 :(得分:0)
使用fuild.casefold()
print("Is the fluid water/steam or R-134a: ")
fluid = input()
if fluid.casefold() == "water":
hin = CP.PropsSI('H','P', pin,"T",lower_temp+zeroC, 'water')
hout = CP.PropsSI('H','P', pout,"T",upper_temp+zeroC, 'water')
return
elif fluid.casefold() == "r134a" or fluid.casefold() == "r-134a":
hin = CP.PropsSI('H','P', pin,"T",lower_temp+zeroC, 'R134a')
hout = CP.PropsSI('H','P', pout,"T",upper_temp+zeroC, 'R134a')
return
else:
print("Invalid Fluid")
params()