gpt4 book ai didi

python - 第 36 行语法错误

转载 作者:行者123 更新时间:2023-12-01 04:23:13 25 4
gpt4 key购买 nike

我在基于文本的冒险的第 36 行不断收到语法错误。

我在该行末尾添加了 #line 36 来告诉您它在哪里。我已经尝试了所有我能想到的方法来解决这个问题。我错过了什么?

#Adventure
#Setting
print ("*You wake up in a dark room on a mattress that is on the floor*")
#Wait before running next command to make it seem more real and more like a real thought.
import time
time.sleep(1)
#Introduce the Map
print ("*You look to your left and there is a wall, you then look to your right and find a short table with a map on it*")
import time
time.sleep(1)
print("*You pick up the map*")
map = """
|---------------------|
| |
| Start |
| |
| |
|---------------------|"""
print (map)
def goto(linenum):
global line
line = linenum
line = 1
while True:
if line == 1:
response = raw_input("Would you like to explore around the room or move to next the room? (Type explore ,or move-on): ")
if response == "explore":
map = """
|---------------------|---------------------|
| | |
| Start | Room 2 |
| | |
| | |
|---------------------|---------------------|"""
print (map)
elif response = "move-on": #line 36
map = """
|-------------------------------------------|
| |
| [Chest] |
| D |
| O |
| O |
| (table) R |
| {Bed} |
|-------------------------------------------|"""
print (map)
else:
goto(100)

break
elif line == 100:
print "Your input is invalid"
goto(1)

最佳答案

您不需要多次导入模块(即,只需在开始时导入时间一次)..

话虽这么说,你打印声明:

print (map)

缩进不正确(两次都被称为[第35行和第47行])

可能还有其他问题,但这就是您的代码当前正在崩溃的问题。

关于python - 第 36 行语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33447062/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com