如何在我的python程序中修复此错误?

时间:2015-03-13 11:07:35

标签: python variables reference

你好我是python的新手,我正在尝试制作冒险游戏,我与另一个玩家进行了第一次“随机”遭遇,我似乎无法让它工作我一直收到以下错误“ UnboundLocalError:在赋值之前引用的局部变量'PL1ST'“我不知道错误意味着什么,有人可以让我知道吗?并且最好是如何防止它,错误来自的代码就在这里

if PL1ST == PLA2ST:
    print "Your warriors are equally strong!"
elif PL1SK == PLA2SK:
    print "Your warriors are equally skilled!"
elif PL1ST == PLA2ST and PL1SK == PLA2SK:
    print "Your warriors are completely equal!"
elif PL1ST > PLA2ST:
    print char1,"is stronger than",char2 ,"!"
    print char2, "has lost!"
elif PLA2ST > PL1ST:
    print char2,"is stronger than",char1 ,"!"
    PL1ST == PL1ST - PLA2ST
elif PL1SK > PLA2SK:
    print char1,"is more skilled than",char2 ,"!"
elif PL1SK < PLA2SK:
    print char2,"is more skilled than",char1 ,"!"
elif PL1SK <= 0:
    print char1, "is out of skill!"
    PL1SK == 0 
elif PLA2SK <= 0:
    print char2, "is out of skill!"
    PLA2SK == 0

0 个答案:

没有答案