我正在使用easygui | Python。
import easygui as eg
fields = ["juvenile","adult","senile"];
message = "Please fill in the boxes";
windowtitle = "set generation values";
while True:
inputvalues = eg.multenterbox(message, windowtitle, fields);
valid = True;
if inputvalues == None:
eg.msgbox("You did not fill out the boxes!", "error");
continue;
for value in inputvalues:
if value == "":
valid = False;
break;
if valid == True:
break;
else:
eg.msgbox("You did not fill in one of the boxes!", "error");这是我做的多人盒子。我需要关于如何使用多项框中的值的帮助。例如:
if juvenile == 100:
eg.msgbox("there are 100 juveniles in your population")我的这部分代码没有响应,有人知道解决方案吗?
发布于 2016-12-11 06:24:57
我认为您的问题是,您正在尝试检查juvenile是否为int,但multenterbox返回了一个字符串列表。
所以这可能会解决这个问题:
if juvenile=="100":
eg.msgbox("there are 100 juveniles in your population")发布于 2019-07-21 03:55:12
因为Easygui返回List,所以使用rescriptable (我不知道它叫什么,但我称之为它!)函数,我指的是[start, end, (action)]。
因此,因为juvenile是第一个,所以我们将这样做:
if inputvalues[0] == "100": # It needs to be `0` in `[]` because it means first. Second is `1` and continue
# Do something并继续
https://stackoverflow.com/questions/37569889
复制相似问题