commit de73c5c0d5e4844b780b5424a9306f114251e0e7 Author: zheshi <2235948935@qq.com> Date: Tue Oct 6 19:51:12 2026 +0800 上传文件至「/」 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