-1

当我在计算器中按任何数字时显示错误

from tkinter import *

def btnclick (numbers):
    global operator
    operator=operator + str(No)
    text_Input.set(operator)

def btnClearDisplay():
    global operator
    operator=""
    text_Input.set("")

def btnEqualsInput():
     global operator
     sumup=str(eval(operator))
     text_Input.set(sumup)
     operator=""

错误:

line 5, in btnclick
    operator=operator + str(No)
NameError: name 'No' is not defined
4

2 回答 2

2

试试这个:operator = operator + str(numbers)因为你的函数参数是numbers.

于 2020-05-24T04:59:56.120 回答
1

纠正这个numbers

operator=operator + str(numbers)

运行程序后

于 2020-05-24T05:05:42.087 回答