我的飞轮海到凯尔丘斯/开尔文监狱有麻烦吗

2024-09-26 22:54:59 发布

您现在位置:Python中文网/ 问答频道 /正文

# Fahrenheit to Celcius    
def f2c():
    userInput = tempEntry.get().lower()
    thisEquation = "Fahrenheit to Celcius"
    if userInput == "":
        textWid.insert(END,"-- " + thisEquation + " --")
        textWid.insert(END,"\n")
        textWid.insert(END,temp_equations[thisEquation])
        textWid.insert(END,"\n")
        textWid.insert(END,"\n")
    elif userInput.isdigit():
        textWid.insert(END,"Fahrenheit = ")
        textWid.insert(END,str(((float(userInput) - 32) * (5/9))))
        textWid.insert(END,"\n")
    else:
        textWid.insert(END,"Invalid entry for"+" "+thisEquation)
        textWid.insert(END,"\n")

# Fahrenheit to Kelvin
def f2k():
    userInput = tempEntry.get().lower()
    thisEquation = "Fahrenheit to Kelvin"
    if userInput == "":
        textWid.insert(END,"-- " + thisEquation + " --")
        textWid.insert(END,"\n")
        textWid.insert(END,temp_equations[thisEquation])
        textWid.insert(END,"\n")
        textWid.insert(END,"\n")
    elif userInput.isdigit():
        textWid.insert(END,"Fahrenheit = ")
        textWid.insert(END,str(((5/9)*(float(userInput) - 32) + 273.15)))
        textWid.insert(END,"\n")
    else:
        textWid.insert(END,"Invalid entry for"+" "+thisEquation)
        textWid.insert(END,"\n")

userInput是一个全局定义的Tkinter输入框。 我强烈怀疑我的问题源于这两个方程,但我已经多次尝试重新处理它们。在

我的华氏度到摄氏度的转换器总是返回0.0 华氏温度到开尔文的转换器每次大约关闭20度。在

伙计们,如果能帮上忙,我将不胜感激。在


Tags: togetifdeflowertempendinsert

热门问题