Py学习  »  Python

我的Python温度转换器不工作

Nineteenn • 4 年前 • 1698 次点击  

我试着做一个温度转换器,但由于某种原因它不能工作,这是我的代码

def getinput():
    print("Enter the temperature")
    a = float(input())
def Converter():
    print("Press 1 for Fahrenheit to Celsius\nPress 2 for Celsius to Fahrenheit")
    x = int(input())
    if x == 1:
       a = getinput()
       return (a - 32) * 5/9
    if x == 2:
        a = getinput()
        return (a + 32) * 9/5

Converter()
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/132340
文章 [ 1 ]  |  最新文章 4 年前