while True: a = input("摄氏转华氏请按1\n华氏转设施请按2\n") if a == '1': celsius = float(input('输入摄氏温度')) fahrenheit = (celsius * 1.8) + 32 print('{:.2f}摄氏温度转为华氏温度为{:.2f}'.format(celsius, fahrenheit)) elif a == '2': fahrenheit = float(input('输入华氏温度')) celsius = (fahrenheit - 32) / 1.8 print('{:.2f}摄氏温度转为华氏温度为{:.2f}'.format(celsius, fahrenheit)) else: break
华氏转设施请按2 1 输入摄氏温度100 100.00摄氏温度转为华氏温度为212.00 摄氏转华氏请按1 华氏转设施请按2 2 输入华氏温度100 37.78摄氏温度转为华氏温度为100.00 摄氏转华氏请按1 华氏转设施请按2