李昀芯eval函數圖形介面計算機
程式碼 from tkinter import * def button_press(num): global equation_text equation_text = equation_text + str(num) equation_label.set(equation_text) def equals(): global equation_text try: total = str(eval(equation_text)) equation_label.set(total) equation_text = total except SyntaxError: equation_label.set("syntax error") equation_text = "" except ZeroDivisionError: equation_label.set("arithmetic error") equation_text = "" def clear(): global equation_text equation_label.set("") equation_text = '' window = Tk() window.title('李昀芯拷貝美國人的程式碼') window.geometry("500x500") equation_text = "" equation_label = StringVar() label = Label(window, textvariable=equation_label, font=('consolas',20), bg="pink", width=24, height=2) label.pack() frame = Frame(window) frame.pack() button1 = Button(frame,...