1 -*- coding:utf-8 -*- 2 #Author:\'Lmc\' 3 #DATE: 2019/4/23/0023 下午 4:23:08 4 #FileName:tem_compare_gui.PY 5 import easygui 6 string = \'\' #初始化 7 8 def tem_compare(string): 9 string = easygui.choicebox(\'请选择功能!\', choices=[\'摄氏温度转华氏温度\', \'华氏温度转摄氏温度\']) 10 while string == \'摄氏温度转华氏温度\': 11 c = float(easygui.enterbox(\'请输入摄氏温度\')) 12 f = c * 1.8 + 32 #华氏温度转摄氏温度公式 13 f1 = float(\'%.1f\'%f) 14 easygui.msgbox(\'华氏温度为\'+ str(f1)) 15 tem_compare(string) 16 break 17 18 while string == \'华氏温度转摄氏温度\': 19 f = float(easygui.enterbox(\'请输入华氏温度\')) 20 c = (f - 32) / 1.8 #摄氏温度转华氏温度公式 21 c1 = float(\'%.1f\'%c) 22 easygui.msgbox(\'温度度为\' + str(c1)) 23 tem_compare(string) 24 break 25 26 tem_compare(string)