我一直在关注这一系列 youtube 视频,以便更多地了解 Python。我对某些代码的作用没有深入的了解,但我或多或少地了解了每个部分应该实现的目标,即使我可能不确定如何实现。
我在此处的最后一行收到语法错误:
class Character(object):
def __init__(self, name, hp):
self.name = name
self.hp = hp
self.dead = False
def attack(self, other):
pass
def update(self):
if self.hp < 0 #Error's on this line
self.dead = True
self.hp = 0
这是回溯:
Traceback (most recent call last): File "game.py", line 4, in
<module>
from Characters.player import * File "/Users/Devlin/Desktop/Dev/Python/rpg/Characters/player.py", line 2,
in <module>
from character import * File "/Users/Devlin/Desktop/Dev/Python/rpg/Characters/character.py", line
12
if self.hp < 0
^ SyntaxError: invalid syntax