华氏度与摄氏度转换器:在线温度单位转换工具
temp = input() if temp[-1] == 'C': try: celsius = float(temp[:-1]) fahrenheit = celsius * 1.8 + 32 print('%.2fF' % fahrenheit) except: print('输入格式错误') elif temp[-1] == 'F': try: fahrenheit = float(temp[:-1]) celsius = (fahrenheit - 32) / 1.8 print('%.2fC' % celsius) except: print('输入格式错误') else: print('输入格式错误')
原文地址: https://www.cveoy.top/t/topic/mJUW 著作权归作者所有。请勿转载和采集!