【发布时间】:2015-07-04 04:51:51
【问题描述】:
所以我的 Python 游戏中的这行代码不起作用:
direction=raw_input("What would you like to do?\n")
它应该让玩家输入一个命令:北、南、东、西、看、搜索、命令或库存。它想出了这个:
Traceback(最近一次通话最后一次): 文件“/Users/khalilismail/Desktop/COMPUTING/Text-based Games/DragonQuest.py”,第 173 行,在 direction=raw_input("你想做什么?\n") EOFError: 读取一行时出现EOF
请帮忙
以下是围绕此的代码堆栈: 当游戏==开启时:
while place==town:
direction=raw_input("What would you like to do?\n")
if direction=="west":
if "iron ore" and "wood" and "3 Gold Pieces" in items:
print "The blacksmith greets you, and you tell him that you have the items and money he requires, you also give him the saw to make up for some of the difference, he then forges you a battleaxe and wishes you luck on the rest of your quest"
items.remove ("saw")
items.remove ("3 Gold Pieces")
items.remove ("iron ore")
items.remove ("wood")
items.append ("battleaxe")
【问题讨论】:
-
你能用围绕这一行的代码行来编辑你的问题吗?
-
你是如何运行这段代码的?
-
出现错误时输入什么?还有你在哪里运行它?
-
你在使用 Sublime Text 吗?有些人对此stackoverflow.com/questions/17758782/… 有一些麻烦
-
除此之外:您的
if "iron ore" and "wood"等行并没有按照您的想法进行。
标签: python debugging command raw-input adventure