卓詠瀅GUI計算機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 = ...