在Python中退出脚本命令

时间:2016-05-16 07:25:37

标签: string python-3.x exit

首先,我是编码的新手。 为了练习基本的字符串和命令,我正在做一个基于决策的游戏,你知道经典的左或右类型的东西。问题是我不知道退出命令。我把它写到了哪里如果你做出某些选择你就死了,当你死的时候我想把它写到脚本引导你的地方。有点像

print('You have died..exit?')

user_choice = input('Okay')

if user_choice == 'Okay':

(here is where i would put the exit code)

else:

(Exit code again...no getting out of it)

请帮忙!我今天刚刚开始编码...>。<

1 个答案:

答案 0 :(得分:0)

很好地关闭你可以

的程序
import sys

然后随时随地:

sys.exit(0)

Is there a method that tells my program to quit?