From de73c5c0d5e4844b780b5424a9306f114251e0e7 Mon Sep 17 00:00:00 2001 From: zheshi <2235948935@qq.com> Date: Tue, 6 Oct 2026 19:51:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=E3=80=8C/=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- geji.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 geji.py diff --git a/geji.py b/geji.py new file mode 100644 index 0000000..e99309d --- /dev/null +++ b/geji.py @@ -0,0 +1,18 @@ +class Geji: #父类歌姬 + def __init__(self, name, color): + self.name = name + self.color = color + def show(self): #父方法 + print(f"{self.name} is {self.color}") +class RedGeji(Geji): #红子类 + def show(self): # 重写方法 + print(f"{self.name} is {self.color},红必秒蓝") +class BlueGeji(Geji): #蓝 + def show(self): + print(f"{self.name} is {self.color},蓝必秒红") +teto = RedGeji("teto", "red") +miku = BlueGeji("miku", "blue") +def go(geji): + geji.show() +go(teto) +go(miku) \ No newline at end of file