天天看點

python quit函數_在Python中啟用quit函數的問題

一般來說,我對程式設計很陌生,我正在為我妹妹制作一個小遊戲。。。在

我有一個while循環,我想有一個退出遊戲的選項,但我所知道的退出技巧似乎都不起作用:#main game:

while 1:

input_event_1 = gui.buttonbox(

msg = 'Hello, what would you like to do with your Potato Head?',

title = 'Main Screen',

choices = ('Check Stats', 'Feed', 'Exercise', 'Teach', 'Play', 'Go to Doctor', 'Change Favourite Thing', 'Get New Toy', 'Quit'))

if input_event_1 == 'Check Stats':

myPotatoHead.check_p_h_stats()

if input_event_1 == 'Change Favourite Thing':

myPotatoHead.change_favourite_thing()

if input_quit == 'Quit':

input_quit = gui.ynbox(

msg = 'Are you sure you want to quit?',

title = 'Confirm quit',

choices = ('Quit', 'Cancel'))

if input_event_quit == 'Quit':

sys.exit(1)

感謝你的幫助。在

謝謝

-----更新-----

謝謝你的建議,但還是沒用:

以下是更新後的代碼:

^{pr2}$

我在Mac上使用Python2.5.4

我用的是Easygui 0.83

再次感謝你的建議