将元组入口变量转换为数学问题的int的问题



目前我一直在尝试将我的元组变量:tempLentry、windLentry和dewpointLentry转换为整数,以便在数学序列中使用它们。然而,每当发生这种错误时,我都会不断收到:TypeError:int((参数必须是字符串、类似字节的对象或实数,而不是"Entry"。我希望有人能指出正确的方向,谢谢!

代码低于

def calc ():    
#Tuple being recieved from askUser
tempLentry,windLentry,dewpointLentry = askUser()
#Converts string input from entries to integers for the calculations to work.
t = int(tempLentry)
ws = int(windLentry)
dp = int(dewpointLentry)
#Checks to see if inputed data for temperature and windspeed is less than 50mph and 
greater than 3 mph
if (t < 50 and ws > 3):
windchill = (35.74 + 0.6215 * t - (35.75 * math.pow(ws,0.16)) + (0.4275 * t * math.pow(ws,0.16)))
else:
windchill = 0

您需要首先将Entry转换为字符串,然后将其强制转换为int。

您可以使用.get()将条目作为字符串获取

t = int(tempLentry.get())
ws = int(windLentry.get())
dp = int(dewpointLentry.get())

最新更新