|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 python羊 于 2020-3-17 14:50 编辑
运行的时候没有问题,当点击右上角的 X 关闭,或者点击 ‘CANCEL’关闭该程序的时候报错
代码如下:
————————————————————————————————————————————
import easygui as g
import sys
name_aidekang = '康,ADK'
name_aidr = '尔,ADE'
name_aideyang = '扬,ADY'
msg = '输入名称'
title = '客户要求'
name = g.enterbox(msg,title)
while True :
if name in name_aidekang:
g.msgbox('找到了ADK。康')
name = g.enterbox(msg,title)
elif name in name_aidr :
g.msgbox('找到了ADE 尔')
name = g.enterbox(msg,title)
elif name in name_aideyang :
g.msgbox('找到了ADY 扬')
name = g.enterbox(msg,title)
else:
g.msgbox('未查询到此客户')
name = g.enterbox(msg,title)
————————————————————————————————————————————
报错内容:
——————————————————————————————————————————————————————
>>>
Traceback (most recent call last):
File "C:/Users/PC-19/Desktop/实验室助手/实验室助手1.0 测试.py", line 13, in <module>
if name in name_aidekang:
TypeError: 'in <string>' requires string as left operand, not NoneType
>>>
>>>
——————————————————————————————————————————————
你是完全不会看这些错误提示吗?
TypeError: 'in <string>' requires string as left operand, not NoneType
这是说你的语句if name in name_aidekang:中in左侧的变量name类型不对。
你看一下name = g.enterbox(msg,title) enterbox的返回值是什么类型。应该是需要类型转换
|
|