运行程序时出现类型错误。无法将条目存储为整数

2024-04-29 08:54:54 发布

您现在位置:Python中文网/ 问答频道 /正文

所以,我试图制作一个程序,它接受你输入的骰子数量(最多5个),然后生成随机的骰子数。但是,当我运行此代码时:

diceAmount = Entry(root)
diceAmount.grid(row=1)
diceAmountint = int(diceAmount)

我一直收到以下错误消息:

int() argument must be a string, a bytes-like object or a number, not 'Entry'

我在网上的任何地方都找不到使用tkinter条目显示该错误消息的其他人


Tags: 代码程序消息数量错误root骰子argument
1条回答
网友
1楼 · 发布于 2024-04-29 08:54:54

int()函数不知道如何将Entry对象转换为int值。您需要从Entry对象的某些属性或方法中提供字符串、字节或数值,并将其传递到int(…)调用中

相关问题 更多 >