Python子类/父类,子类返回两次字符串?

一个简单的问题,也许对你们中的一个人很明显,但是我不确定为什么会发生。因此,这是Ive制作的三个python文件。


主要字符类:


class Character():

    """

    This is the main parents class for creation of

    characters, be they player, NPC or monsters they

    shall all share common traits

    """


    def __init__(self, name, health, defense):

        """Constructor for Character"""

        self.name = name

        self.health = health

        self.defense = defense

玩家等级:


from character import *


class Player(Character):

    """

    The player class is where heros are made

    They inherit common traits from the Character class

    """


    def __init__(self, name, health, defense, str, int):

        Character.__init__(self, name, health, defense)

        self.str = str

        self.int = int

在里面:


from Letsago.player import Player



hero = Player("Billy", 200, 10, 10, 2)    

print hero.name

结果是:


Billy

Billy

为什么要退回两次?


饮歌长啸
浏览 177回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python