所以,我对python和半新一般的编码很新,我很难将简单的变量打印出来。
#startup
startup = "welcome to 'da spoopy house', type 'start'"
work = raw_input(startup)
<here is full code>
#functions
#keywords
varlook = "look"
vargo = "go"
varhouse = "house"
#story
st01 = "You are outside, its dusk. there is a house in front of you. both you and the house are surrounded by a forest"
st02 = "You walk up to the house, you notice a small yard with flowers lining the perimeter. As you step up to the door, you notice a small note attached to the door"
#instructions... ?
#action
print st01
raw_input()
if varlook in work:
print "%s" % st01
raw_input()
if raw_input == ("%s to %s") % (vargo, varhouse):
print "%s" % st02
raw_input()
问题出在这里
#action
print st01
raw_input()
if varlook in work:
print "%s" % st01
raw_input()
if raw_input == ("%s to %s") % (vargo, varhouse):
print "%s" % st02
raw_input()
当我输入所需的关键字时,它只是停止程序,让我回到空闲状态。 任何帮助表示赞赏。
答案 0 :(得分:1)
您似乎误以为对函数raw_input
的调用,即发出raw_input()
会将输入字符串分配给名为raw_input
的变量。
实际上,会发生的是函数调用返回一个字符串,您当前无法使用该字符串 - 该字符串将被垃圾收集并丢失,因为您没有任何引用它
将一个变量赋值给返回值,然后使用以下代码中的变量。
演示:
>>> user_input = raw_input()
hello Emmma!
>>> print user_input
hello Emmma!