我刚刚开始学习,我正在编写一个简单的块。它要求输入名称然后停止。这就是我得到的http://imgur.com/KTwQz6G,但前提是我从IDLE粘贴。如果我从这个网站复制它似乎工作。也许是因为我使用旧版本的IDLE来编写它?
name = raw_input("What is your name? ")
color = raw_input("What is your favorite color? ")
print "Well, Hello %s. I was hoping you would pick dark brown,
but %s is cool too." % (name, color)
答案 0 :(得分:1)
该计划不会立即提出所有问题。当您通过raw_input方法提示时输入名称,然后输入颜色相同的名称。例如:
>>>python file.py
What is your name? somename #you type somename and press enter
What is your favorite color? somecolor #you type somecolor and press enter
Well, Hello somename. I was hoping you would pick dark brown, but somecolor is cool too.
答案 1 :(得分:1)
它要求提供名称。用户必须在提示中键入它,然后按Enter键以使代码继续执行。这就是raw_input的作用。