Traceback (most recent call last):
File blahblah, line 21, in <module>
enemy1 = Enemy(50, 69)
TypeError: Enemy() takes no arguments
Process finished with exit code 1
==
代码如下:
import random
class Enemy:
HP = 200
def _init_(self, atkl, atkh):
self.atkl = atkl
self.atkh = atkh
def getAtk(self):
print("atk is", self.atkl)
def getHP(self):
print("HP is", self.hp)
enemy1 = Enemy(50, 69)
enemy1.getAtk()
enemy1.getHP()
enemy2 = Enemy(75, 90)
enemy2.getAtk()
enemy2.getHP()
...
任何想法为什么我都会收到以下行的错误消息:敌人1 =敌人(50,69)