我已经编写了以下代码,如果else语句为真,我希望程序关闭。我是python新手,遇到了一些麻烦
password = raw_input('Enter yes to continue:')
if password == 'yes':
print'You have chosen to continue'
else:
print'You have chosen to exit'
添加到您的代码
import sys # This goes at the header
...
if password == 'yes'
pass # Your code goes on... I put the 'pass' just as a place holder
else
sys.exit()
import sys
if condition is true:
pass
# or your operating row.
else:
sys.exit()