m0_58397762 2021-05-19 12:06 采纳率: 100%
浏览 308
已采纳

Python 自定义函数 温度转换

def num(): while True: temp=input("请输入带有符号的温度数值:") if temp[-1] in ['c','C','f','F']: return temp else: print("输入错误,请输入带有符号的温度数值") def progress(temp): if temp[-1] in ['F','f']: output=(eval(temp[:-1])-32)/1.8 print("温度转换为摄氏度为{:.2f}C".format(output)) else : output=eval(temp[:-1])*1.8+32 print("温度转换为华氏度为{:.2f}F".format(output)) temp=num() progress(temp) 这个程序只能运行一次是哪处的问题?

  • 写回答

4条回答 默认 最新

  • CSDN专家-kaily 2021-05-19 13:18
    关注

    你的num()函数,里面有一个while,当return之后就跳出循环了啊,所以就只能运行一次,所以你出什么问题了?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了