首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >多个raw_inputs

多个raw_inputs
EN

Stack Overflow用户
提问于 2011-02-22 19:24:20
回答 2查看 2.6K关注 0票数 1
代码语言:javascript
运行
复制
#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!                              #"

这是我的代码。我的问题是,在第一个输入完成后,他们的下一个输入将以">>>“作为前缀。我该如何改变这一点,而且我总是得到“无效的选择!”在当前代码中。请帮帮忙,谢谢!

EN

回答 2

Stack Overflow用户

发布于 2011-03-27 18:32:42

代码语言:javascript
运行
复制
#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]
票数 0
EN

Stack Overflow用户

发布于 2013-12-14 15:08:17

我认为您需要像这样编码您的新行‘\n’您必须输入1、2或3。‘’\n‘

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5077450

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档