在模块内部调用函数

时间:2018-09-30 14:26:29

标签: python-3.x

所以,我制作了这个模块,并将其命名为Dragon。

class Dragon:
        trapped = 0
        size = 0
        dragonName = 0
        def incounter(self):
            import random
            self.size = random.randrange(1,14)
            if self.size >10:
                return("It is arguably one of the most large dragon you've ever met in wild.")
            elif 11 > self.size >4:
                return("Its size is not notably small nor large. At best, its isn't remarkable.")
            else:
                return("Its size is remarkably small, even if you consider that it almost never had any compounds before.")
            self.dragonName = input('You decide to name it: ')

我导入了,然后做了

Mary = Dragon.Dragon

然后,

Mary.incounter

哪个给了我蓝色

<function Dragon.incounter at 0x106098950>

不是我应该得到的。

有人可以帮助我解决这个问题,例如如何使其真正起作用吗?

如果我做错了什么,请告诉我。我只是一个刚认识Python三天的学生。

0 个答案:

没有答案