下面这段python代码中fahr未定义是何含义,pythonfahr,cel = float(


cel = float(5 / 9*(fahr - 32))Traceback (most recent call last):  File "<pyshell#31>", line 1, in <module>    cel = float(5 / 9*(fahr - 32))NameError: name 'fahr' is not defined

你得先写个:

    fahr=100    #然后    cel = float(5 / 9*(fahr - 32))

但是我估计你是想写个函数,所以你需要:

def f(fahr):    cel = float(5 / 9*(fahr - 32))    return cel

编橙之家文章,

评论关闭