0

当我返回一个值时,它怎么不输出呢?这可能真的很简单......顺便说一句,我目前仍在学习 Python。我正在使用 Python 3.x。

def convert(operation, temp):
    newTemp = 0
    if (operation is 'F' or operation is 'f'):
        newTemp = (9/5) * (temp + 32)
        return newTemp
    if (operation is 'C' or operation is 'c'):
        newTemp = (5/9) * (temp - 32)
        return newTemp

print ("What operation would you like to convert to? ")
op = input("(F)ahrenheit or (C)elsius: ")
print ()
temp = input("What is the temperature : ")
NewTemp = int(temp)
convert(op, NewTemp)

谢谢

4

2 回答 2

0

你从来没有告诉它打印结果。尝试这个:

print(convert(op, NewTemp))
于 2013-05-26T01:20:41.053 回答
0

您需要print返回的值convert(op, NewTemp)

print(convert(op, NewTemp))
于 2013-05-26T01:20:48.193 回答