tempstr=input("请输入带符号的温度值") if tempstr[-1] in ['F','f']: '''#:是语法内的内容''' C = (eval(tempstr[0:-1])-32)/1.8 print("转换后的温度是{:.2f}C".format(C)) elif tempstr[-1] in ['C','c']: F=1.8*eval(tempstr[0:-1])+32 print("转换后的温度{:.2f}F".format(F)) else: print("输入格式错误")
python的温度转换
猜你喜欢
转载自blog.csdn.net/qq_36958104/article/details/81298300
今日推荐
周排行