我是python的新手,无法理解此代码出了什么问题 这是错误:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\sarvinoz.toshpulotov\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "C:/Users/sarvinoz.toshpulotov/Desktop/PROJECT2/Project.py", line 34, in getter
a[int(coef1.get())] = int(pow1.get())
ValueError: invalid literal for int() with base 10: ''
这是我的代码的一部分:
from tkinter import *
class Derivat:
def length():
l = w
global numb
frame1 = Frame(l)
title = Label(frame1, text = "Enter the length of your expression:", font= ("arial", 14), bg = "skyblue")
title.grid(row = 0, column = 0, padx = 5, pady = 5)
numb = Entry(frame1, width = 10)
numb.grid(row=0, column=2)
frame1.pack(side=TOP, pady=5, padx=5, ipadx = 5, ipady = 5)
result = Button(frame1, text="Enter:", bg="green")
result.grid(row=0, column=3, padx =10, pady =10)
result.config(command=Derivat.getter)
def getter():
m = w
f = int(numb.get())
frame2 = Frame(m)
frame3 = Frame(m)
a = {}
coef = Label(frame2, text="Enter your coefficients accordingly:")
coef.grid(row=0, column=0)
power = Label(frame3, text="Enter the power's of the x accordingly:")
power.grid(row=10, column=0)
for i in range(f):
coef1 = Entry(frame2)
coef1.grid(row=20, column=i)
pow1 = Entry(frame3)
pow1.grid (row = 30, column = i)
a[int(coef1.get())] = int(pow1.get())
frame2.pack(side=LEFT, pady=5, padx=5, ipadx=5, ipady=5)
frame3.pack(side=LEFT, pady=5, padx=5, ipadx=5, ipady=5)
print(a)