语法错误:无法分配给运算符

时间:2016-12-24 20:01:29

标签: python python-3.x

我在第27行有一个非常特殊的问题:Syntax Error: can't assign to operator。我不知道为什么会这样,我花了几个小时在这个网站上寻找答案,但没有任何帮助。该程序处于开发的早期阶段,如果您可以帮助我找到更多问题,那将会很酷:

from time import sleep
from random import randint

print("Welcome to a text version of World of Tanks. Choose your tank: PzII(1) T-26(2) CruiserIII(3) Ha-Go(4) M2 Light(5)")

Tank="PzII"
shoot_PzII(Tank)
if(Damage_Approved):
    print("You dealt",Damage_To_Enemy,"points of damage to the enemy.")
else:
    print("You didn't penetrate enemy armour.")

#PzII
Hitpoints=260
Accuracy_PzII_IN%=80
Penetration_PzII=49
Damage_PzII=range(9,15)
Armor_Front_PzII=30
Armor_SIdes_PzII=20
Armor_Rear_PzII=15
Armor_Front_Turret_PzII=30
Armor_Sides_Turret_PzII=20
Armor_Rear_Turret_PzII=20

#PzII Enemy
Hitpoints_Enemy=260
Accuracy_PzII_IN%_Enemy=80
Penetration_PzII_Enemy=range(29,49)
Damage_PzII_Enemy=range(9,15)
Armor_Front_PzII_Enemy=30
Armor_SIdes_PzII_Enemy=20
Armor_Rear_PzII_Enemy=15
Armor_Front_Turret_PzII_Enemy=30
Armor_Sides_Turret_PzII_Enemy=20
Armor_Rear_Turret_PzII_Enemy=20

def shoot_PzII(Tank):
    Shot_land_n=randint(0,2)
    if(Tank=="PzII"):
        if(Shot_land_n==1):
            Shot_land=Turret
            Accuracy_PzII_IN%_InSituation=Accuracy_PzII_IN%-(Distance_To_Enemy/2)
            if(randint(0,100)<=Accuracy_PzII_IN%_InSituation):
                If_Try_Damage=True
            else:
                If_Try_Damage=False
            if(If_Try_Damage):
                if(Penetration_PzII>Armor_Front_Turret_PzII_Enemy):
                    Damage_To_Enemy=randint(Damage_PzII)
                    Damage_Approved=True
                    Hitpoints_Enemy=Hitpoints_Enemy-Damage_To_Enemy
                else:
                    Damge_Approved=False

1 个答案:

答案 0 :(得分:1)

Python正在解释:

swipe3DRotateView.setCompleteAnimationCompleteListener(fullListener);

为:

Accuracy_PzII_IN%_Enemy=80
当您尝试在名称(Accuracy_PzII_IN % _Enemy) = 80 Accuracy_PzII_IN之间为模数运算符赋值时,

是不允许的。

只需删除&#39; name&#39;的百分号你试图定义,不应该使用Python用于常见操作的标记(即_Enemy等等)。