为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

饮歌长啸 2021-03-19 14:10:14
一个简单的问题,也许对你们中的一个人很明显,但是我不确定为什么会发生。因此,这是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 Playerhero = Player("Billy", 200, 10, 10, 2)    print hero.name结果是:BillyBilly为什么要退回两次?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 176 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号