cql123 发表于 2018-5-27 10:03:29

python中的一段程序不懂

本帖最后由 cql123 于 2018-5-27 10:04 编辑

import easygui as g
msg="Enter your personal information"
title="Credit Card Application"
fieldNames=["Name","Street Address","City","State","ZipCode"]
fieldValues=[]
fieldValues=g.multenterbox(msg,title, fieldNames)
while 1:
    if fieldValues == None: break                   #如果filedValues为空的话,就跳出循环了吗?,我运行代码,如果不输入任何东西的话,程序也没有跳出循环,这是为什么?,这句代码有什么用?
    errmsg= ""
    for i in range(len(fieldNames)):
      if fieldValues.strip() == "":
            errmsg+= ('"%s" is a required field.\n\n' % fieldNames)
    if errmsg == "":
      break # no problems found
    fieldValues =g.multenterbox(errmsg, title, fieldNames, fieldValues)

ba21 发表于 2018-5-27 11:17:46

点 取消 返回 None

BngThea 发表于 2018-5-27 11:58:08

请查看multenterbox的返回值情况

Cpig 发表于 2018-5-28 23:47:02

把none改为[]{:10_279:}
页: [1]
查看完整版本: python中的一段程序不懂