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) 这个程序只能运行一次是哪处的问题?

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

代码看上去没多大问题,你的运行方式是怎样的。截图看看

您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632

能不能把缩进处理一下,然后再帮你看问题