Discuss / Python / 交作业

交作业

Topic source

___Hiboboo

#1 Created at ... [Delete] [Delete and Lock User]

这种写法可以说就不是多态了,这特么的是变态啊。

# -*- coding: utf-8 -*-


class Animal(object):

    def speak(self):
        print("Hello, I'm is Animal.")


class Dog(Animal):

    def speak(self):
        print("Hello, I'm is Puppy.")


class Cat(Animal):

    def speak(self):
        print("Hello, I'm is Cat.")


class Botany(object):

    def speak(self):
        print("Hello, I'm is Botany, HaHaHa.")


def start_perform(animal):
    animal.speak()
    # if isinstance(animal, Animal):
    #     animal.speak()
    # else:
    #     raise TypeError("You're not a fucking animal!!!")


start_perform(Botany())

打印结果:

Hello, I'm is Botany, HaHaHa.

孟祥森丶

#2 Created at ... [Delete] [Delete and Lock User]

i'm is .....兄die,初中英语复习下

朱鑫zzzzz

#3 Created at ... [Delete] [Delete and Lock User]

是兄dei.好不好 拼音复习下

兰溪C游

#4 Created at ... [Delete] [Delete and Lock User]

懂, 就完事了


  • 1

Reply