如果我的问题不是很具体或者标题具有误导性,我很抱歉,我一直在尝试用 Python 2.7 制作游戏。到目前为止,一切都很好,但是有一个问题,我收到了一个语法错误,我不知道如何解决它。错误说:“您的程序中有一个错误: *无法分配给文字(Text game.py,第 28 行)”在这一行中,我试图将 'n' 分配为 1,这是代码:
print """
---------------------------------------------
| |
| TEXT GAME: THE BEGINNING! |
| |
---------------------------------------------
"""
print "What is your name adventurer?"
adv_name = raw_input("Please enter a name: ")
print "Welcome " + adv_name + ", I am called Colosso. I am the great hero of the town Isern. \nWhile I was protecting the surrounding forests I was attacked and killed. \nNow I am nothing but a mere spirit stuck in the realm of Life. \nI am here because I swore to slay the corrupt great king Blupri. \nBlupri still lives therefore I cannot travel to the realm of Death. \nI need you to slay him and his minions so I may rest in peace"
print """Do you want to help Colosso?:
1.) Yes (Start playing)
2.) No (Quit)
"""
dside = input("Please enter a number to decide: ")
if dside == 2:
print "I knew you were a coward..."
raw_input('Press Enter to exit')
elif dside == 1:
print "Great! Let's get this adventure started"
raw_input('Press Enter to continue')
print """This is the tutorial level, here is where you will learn how to play.
To move the letter of a direction, n is north, e is east, s is south, w is west.
Press the '<' key to move up and the '>' key to move down.
Try it!
"""
move = raw_input('Where would you like to go?: ')
"n" = 1
"e" = 2
"s" = 3
"w" = 4
"<" = 5
">" = 6
if move == 1:
print "You move north."
if move == 2:
print "You move east."
if move == 3:
print "You move south."
if move == 4:
print "You move west."
print move
我已经在没有引号和单引号的情况下尝试过,但都没有工作任何帮助或建议表示赞赏。