Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我的文字冒险不会打印[python]_Python_Text - Fatal编程技术网

我的文字冒险不会打印[python]

我的文字冒险不会打印[python],python,text,Python,Text,因此,我对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

因此,我对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()
当我输入所需的关键字时,它只是停止程序,使我回到空闲状态。
感谢您的帮助。

您似乎有一种误解,即调用函数
raw\u input
,即发出
raw\u input()
会将输入字符串分配给名为
raw\u input
的变量

事实上,函数调用会返回一个字符串,您当前对该字符串不做任何操作-该字符串将被垃圾收集并丢失,因为您没有对它的任何引用

为返回值指定一个变量,然后在以下代码中使用该变量

演示:


您忘记在
中调用
raw\u input
,如果raw\u input==(%s到%s”)
您需要在某处添加一个循环。没有它,您的脚本将到达结尾并终止。
#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()
>>> user_input = raw_input()
hello Emmma!
>>> print user_input
hello Emmma!