NameError: name 'No' is not defined

NameError: name 'No' is not defined

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

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

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

更正这个numbers

operator=operator + str(numbers)

在 运行 你的程序之后