#Print out the menu
print """
###############################################
# 1 - Introduction. #
# 2 - Base. #
# 3 - Contact. #
###############################################"""
#Get the user's choice
choice = raw_input("")
#Work with choice
print choice
if choice == 1:
print "# Welcome to xbrEra's first application! #"
elif choice == 2:
print "# This application was built in Python 7.2.1. #"
elif choice == 3:
print "# Contact me at Blackriver.era@hotmail.com #"
else:
print "# Invalid choice! #"这是我的代码。我的问题是,在第一个输入完成后,他们的下一个输入将以">>>“作为前缀。我该如何改变这一点,而且我总是得到“无效的选择!”在当前代码中。请帮帮忙,谢谢!
发布于 2011-03-27 18:32:42
#Print out the menu
ch = """###############################################
# 1 - Introduction. #
# 2 - Base. #
# 3 - Contact. #
###############################################
Enter your choice : """
choice = raw_input(ch)
warn = "\n You must enter 1 or 2 or 3.\n"+\
" Enter your choice : "
while choice not in ('1','2','3'):
choice = raw_input(warn)
print ("# Welcome to xbrEra's first application! #",
"# This application was built in Python 7.2.1. #",
"# Contact me at Blackriver.era@hotmail.com #")[int(choice)-1]发布于 2013-12-14 15:08:17
我认为您需要像这样编码您的新行‘\n’您必须输入1、2或3。‘’\n‘
https://stackoverflow.com/questions/5077450
复制相似问题