我想说的是“如果你要按相等键的东西是一个整数,那就按我的方法做,但是如果是字符串,那么就打印“cos(无论数字)”、“tan(任意数字)”或“sin(任意数字)”。请帮助澄清如何做到这一点。谢谢您。在from tkinter import*
root = Tk()
def btnPress(num):
global result
result = result+str(num)
equation.set(result)
def equalPress():
global result
total = str(eval(result))
equation.set(total)
result = total
def clear():
global result
result = ""
equation.set("")
result = ""
btnWidth = 5
equation = StringVar()
equation.set("Enter your equation.")
calculation = Label(root, textvariable = equation, width = btnWidth*4)
calculation.grid(row = 0, column = 0, columnspan = 4)
Button0 = Button(root, text = "0", command=lambda:btnPress(0), width