easygui示例的msgbox报错
求大佬帮忙解决!报错如下:
=========================== RESTART: F:\daima\1.py ===========================
Traceback (most recent call last):
File "F:\daima\1.py", line 4, in <module>
g.msgbox('welcome to my module program!')
TypeError: 'str' object is not callable
>>>
代码如下:
import easygui as g
import sys
while 1:
g.msgbox('welcome to my module program!')
msg = 'what do you want to learn from me ?'
title = 'this is a small game'
choices = ['laugh', 'cry','make a nice work' ]
choice = g. choicebox(msg, title, choices)
g. msgbox = ('your choice is '+choice)
msg = 'do you want to make another choice ?'
title = 'yes or no'
if g.ccbox(msg, title):
pass
else:
sys.exit() 改成这样:
import easygui as g
import sys
while 1:
g.msgbox('welcome to my module program!')
msg = 'what do you want to learn from me ?'
title = 'this is a small game'
choices = ['laugh', 'cry','make a nice work' ]
choice = g. choicebox(msg, title, choices)
g. msgbox('your choice is '+choice)
msg = 'do you want to make another choice ?'
title = 'yes or no'
if g.ccbox(msg, title):
pass
else:
sys.exit() import easygui as g
import sys
while 1:
g.msgbox('welcome to my module program!')
msg = 'what do you want to learn from me ?'
title = 'this is a small game'
choices = ['laugh', 'cry','make a nice work' ]
choice = g. choicebox(msg, title, choices)
if choice :
g. msgbox('your choice is '+choice)
msg = 'do you want to make another choice ?'
title = 'yes or no'
if g.ccbox(msg, title):
pass
else:
sys.exit()
报错是因为你的choice可能返回的是NoneType,加一步判断即可解决
页:
[1]