{"id":1041836,"date":"2024-12-31T12:52:28","date_gmt":"2024-12-31T04:52:28","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1041836.html"},"modified":"2024-12-31T12:52:30","modified_gmt":"2024-12-31T04:52:30","slug":"python%e5%a6%82%e4%bd%95%e5%ae%9a%e4%b9%89%e4%b8%80%e4%b8%aashape%e7%b1%bb","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1041836.html","title":{"rendered":"Python\u5982\u4f55\u5b9a\u4e49\u4e00\u4e2ashape\u7c7b"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/07c6a5c5-35dd-45d1-bd6e-45c3f51692e3.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"Python\u5982\u4f55\u5b9a\u4e49\u4e00\u4e2ashape\u7c7b\" \/><\/p>\n<p><p> <strong>Python\u5b9a\u4e49\u4e00\u4e2ashape\u7c7b\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528\u7c7b\u548c\u5bf9\u8c61\u3001\u7ee7\u627f\u4e0e\u591a\u6001\u3001\u5c5e\u6027\u4e0e\u65b9\u6cd5\u3001\u4ee5\u53ca\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u7684\u8bbe\u8ba1\u539f\u5219\u7b49\u3002<\/strong> \u5728\u63a5\u4e0b\u6765\u7684\u5185\u5bb9\u4e2d\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u63a2\u8ba8\u5982\u4f55\u5728Python\u4e2d\u5b9a\u4e49\u4e00\u4e2ashape\u7c7b\uff0c\u5e76\u8ba8\u8bba\u4e00\u4e9b\u76f8\u5173\u7684\u6982\u5ff5\u548c\u6280\u672f\u7ec6\u8282\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u7c7b\u548c\u5bf9\u8c61<\/h3>\n<\/p>\n<p><p>Python\u662f\u4e00\u79cd\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u8bed\u8a00\uff0c\u7c7b\u548c\u5bf9\u8c61\u662f\u5176\u6838\u5fc3\u6982\u5ff5\u3002\u7c7b\u5b9a\u4e49\u4e86\u4e00\u79cd\u65b0\u6570\u636e\u7c7b\u578b\uff0c\u5b83\u5305\u542b\u6570\u636e\uff08\u5c5e\u6027\uff09\u548c\u51fd\u6570\uff08\u65b9\u6cd5\uff09\u3002\u5bf9\u8c61\u662f\u7c7b\u7684\u5b9e\u4f8b\uff0c\u53ef\u4ee5\u8bbf\u95ee\u7c7b\u4e2d\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684shape\u7c7b\u5b9a\u4e49\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class Shape:<\/p>\n<p>    def __init__(self, name):<\/p>\n<p>        self.name = name<\/p>\n<p>    def area(self):<\/p>\n<p>        pass<\/p>\n<p>    def perimeter(self):<\/p>\n<p>        pass<\/p>\n<p>    def __str__(self):<\/p>\n<p>        return f&quot;Shape: {self.name}&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<strong>Shape\u7c7b\u5305\u542b\u4e00\u4e2a\u6784\u9020\u65b9\u6cd5 <code>__init__<\/code>\uff0c\u4e00\u4e2a\u8ba1\u7b97\u9762\u79ef\u7684\u65b9\u6cd5 <code>area<\/code>\uff0c\u4e00\u4e2a\u8ba1\u7b97\u5468\u957f\u7684\u65b9\u6cd5 <code>perimeter<\/code>\uff0c\u4ee5\u53ca\u4e00\u4e2a\u8fd4\u56de\u7c7b\u4fe1\u606f\u7684 <code>__str__<\/code> \u65b9\u6cd5<\/strong>\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u7ee7\u627f\u4e0e\u591a\u6001<\/h3>\n<\/p>\n<p><p>\u7ee7\u627f\u5141\u8bb8\u6211\u4eec\u521b\u5efa\u4e00\u4e2a\u65b0\u7c7b\uff0c\u8be5\u7c7b\u7ee7\u627f\u81ea\u4e00\u4e2a\u5df2\u6709\u7c7b\uff0c\u4ece\u800c\u91cd\u7528\u5df2\u6709\u7c7b\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\u3002\u591a\u6001\u662f\u6307\u5728\u5b50\u7c7b\u4e2d\u53ef\u4ee5\u91cd\u5199\u7236\u7c7b\u7684\u65b9\u6cd5\uff0c\u4ece\u800c\u5b9e\u73b0\u4e0d\u540c\u7684\u884c\u4e3a\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7ee7\u627f\u81eaShape\u7c7b\u7684Rectangle\u7c7b\u548cCircle\u7c7b\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class Rectangle(Shape):<\/p>\n<p>    def __init__(self, name, width, height):<\/p>\n<p>        super().__init__(name)<\/p>\n<p>        self.width = width<\/p>\n<p>        self.height = height<\/p>\n<p>    def area(self):<\/p>\n<p>        return self.width * self.height<\/p>\n<p>    def perimeter(self):<\/p>\n<p>        return 2 * (self.width + self.height)<\/p>\n<p>    def __str__(self):<\/p>\n<p>        return f&quot;Rectangle: {self.name}, Width: {self.width}, Height: {self.height}&quot;<\/p>\n<p>class Circle(Shape):<\/p>\n<p>    def __init__(self, name, radius):<\/p>\n<p>        super().__init__(name)<\/p>\n<p>        self.radius = radius<\/p>\n<p>    def area(self):<\/p>\n<p>        import math<\/p>\n<p>        return math.pi * self.radius  2<\/p>\n<p>    def perimeter(self):<\/p>\n<p>        import math<\/p>\n<p>        return 2 * math.pi * self.radius<\/p>\n<p>    def __str__(self):<\/p>\n<p>        return f&quot;Circle: {self.name}, Radius: {self.radius}&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<strong>Rectangle\u7c7b\u548cCircle\u7c7b\u7ee7\u627f\u81eaShape\u7c7b\uff0c\u5e76\u5206\u522b\u5b9e\u73b0\u81ea\u5df1\u7684<code>area<\/code>\u548c<code>perimeter<\/code>\u65b9\u6cd5<\/strong>\u3002\u540c\u65f6\uff0c<code>__str__<\/code> \u65b9\u6cd5\u4e5f\u88ab\u91cd\u5199\u4ee5\u63d0\u4f9b\u66f4\u591a\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u5c5e\u6027\u4e0e\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u5c5e\u6027\u662f\u7c7b\u4e2d\u5b9a\u4e49\u7684\u53d8\u91cf\uff0c\u7528\u4e8e\u5b58\u50a8\u5bf9\u8c61\u7684\u72b6\u6001\u3002\u65b9\u6cd5\u662f\u7c7b\u4e2d\u5b9a\u4e49\u7684\u51fd\u6570\uff0c\u7528\u4e8e\u5b9e\u73b0\u5bf9\u8c61\u7684\u884c\u4e3a\u3002\u901a\u8fc7\u5728\u7c7b\u4e2d\u5b9a\u4e49\u5c5e\u6027\u548c\u65b9\u6cd5\uff0c\u53ef\u4ee5\u521b\u5efa\u66f4\u52a0\u590d\u6742\u548c\u529f\u80fd\u4e30\u5bcc\u7684\u5bf9\u8c61\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u5305\u542b\u66f4\u591a\u5c5e\u6027\u548c\u65b9\u6cd5\u7684Shape\u7c7b\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class Shape:<\/p>\n<p>    def __init__(self, name, color=&quot;red&quot;):<\/p>\n<p>        self.name = name<\/p>\n<p>        self.color = color<\/p>\n<p>        self.sides = 0<\/p>\n<p>    def set_color(self, color):<\/p>\n<p>        self.color = color<\/p>\n<p>    def get_color(self):<\/p>\n<p>        return self.color<\/p>\n<p>    def set_sides(self, sides):<\/p>\n<p>        self.sides = sides<\/p>\n<p>    def get_sides(self):<\/p>\n<p>        return self.sides<\/p>\n<p>    def area(self):<\/p>\n<p>        pass<\/p>\n<p>    def perimeter(self):<\/p>\n<p>        pass<\/p>\n<p>    def __str__(self):<\/p>\n<p>        return f&quot;Shape: {self.name}, Color: {self.color}, Sides: {self.sides}&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<strong>Shape\u7c7b\u589e\u52a0\u4e86<code>color<\/code>\u548c<code>sides<\/code>\u5c5e\u6027\uff0c\u5e76\u63d0\u4f9b\u4e86\u8bbe\u7f6e\u548c\u83b7\u53d6\u8fd9\u4e9b\u5c5e\u6027\u7684\u65b9\u6cd5<\/strong>\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u8bbe\u8ba1\u539f\u5219<\/h3>\n<\/p>\n<p><p>\u5728\u8bbe\u8ba1\u7c7b\u548c\u5bf9\u8c61\u65f6\uff0c\u5e94\u8be5\u9075\u5faa\u4e00\u4e9b\u57fa\u672c\u7684\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u8bbe\u8ba1\u539f\u5219\uff0c\u5982\u5355\u4e00\u804c\u8d23\u539f\u5219\u3001\u5f00\u653e\u5c01\u95ed\u539f\u5219\u3001\u91cc\u6c0f\u66ff\u6362\u539f\u5219\u3001\u63a5\u53e3\u9694\u79bb\u539f\u5219\u548c\u4f9d\u8d56\u5012\u8f6c\u539f\u5219\u3002<\/p>\n<\/p>\n<p><h4>1. \u5355\u4e00\u804c\u8d23\u539f\u5219<\/h4>\n<\/p>\n<p><p>\u5355\u4e00\u804c\u8d23\u539f\u5219\u8981\u6c42\u4e00\u4e2a\u7c7b\u53ea\u8d1f\u8d23\u4e00\u4e2a\u529f\u80fd\uff0c\u4ece\u800c\u63d0\u9ad8\u7c7b\u7684\u53ef\u7ef4\u62a4\u6027\u548c\u53ef\u8bfb\u6027\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u9075\u5faa\u5355\u4e00\u804c\u8d23\u539f\u5219\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class Shape:<\/p>\n<p>    def __init__(self, name):<\/p>\n<p>        self.name = name<\/p>\n<p>class Color:<\/p>\n<p>    def __init__(self, color):<\/p>\n<p>        self.color = color<\/p>\n<p>shape = Shape(&quot;Circle&quot;)<\/p>\n<p>color = Color(&quot;Red&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<strong>Shape\u7c7b\u548cColor\u7c7b\u5404\u81ea\u8d1f\u8d23\u4e00\u4e2a\u529f\u80fd\uff0c\u4ece\u800c\u4fdd\u6301\u4e86\u5355\u4e00\u804c\u8d23\u539f\u5219<\/strong>\u3002<\/p>\n<\/p>\n<p><h4>2. \u5f00\u653e\u5c01\u95ed\u539f\u5219<\/h4>\n<\/p>\n<p><p>\u5f00\u653e\u5c01\u95ed\u539f\u5219\u8981\u6c42\u7c7b\u5bf9\u6269\u5c55\u5f00\u653e\uff0c\u5bf9\u4fee\u6539\u5c01\u95ed\u3002\u901a\u8fc7\u4f7f\u7528\u7ee7\u627f\u548c\u591a\u6001\uff0c\u53ef\u4ee5\u5b9e\u73b0\u8fd9\u4e00\u539f\u5219\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u9075\u5faa\u5f00\u653e\u5c01\u95ed\u539f\u5219\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class Shape:<\/p>\n<p>    def __init__(self, name):<\/p>\n<p>        self.name = name<\/p>\n<p>    def area(self):<\/p>\n<p>        pass<\/p>\n<p>    def perimeter(self):<\/p>\n<p>        pass<\/p>\n<p>class Rectangle(Shape):<\/p>\n<p>    def __init__(self, name, width, height):<\/p>\n<p>        super().__init__(name)<\/p>\n<p>        self.width = width<\/p>\n<p>        self.height = height<\/p>\n<p>    def area(self):<\/p>\n<p>        return self.width * self.height<\/p>\n<p>    def perimeter(self):<\/p>\n<p>        return 2 * (self.width + self.height)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<strong>\u901a\u8fc7\u7ee7\u627fShape\u7c7b\u5e76\u5b9e\u73b0\u81ea\u5df1\u7684\u65b9\u6cd5\uff0cRectangle\u7c7b\u9075\u5faa\u4e86\u5f00\u653e\u5c01\u95ed\u539f\u5219<\/strong>\u3002<\/p>\n<\/p>\n<p><h4>3. \u91cc\u6c0f\u66ff\u6362\u539f\u5219<\/h4>\n<\/p>\n<p><p>\u91cc\u6c0f\u66ff\u6362\u539f\u5219\u8981\u6c42\u5b50\u7c7b\u80fd\u591f\u66ff\u6362\u7236\u7c7b\uff0c\u5e76\u4e14\u4fdd\u8bc1\u7a0b\u5e8f\u7684\u6b63\u786e\u6027\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u9075\u5faa\u91cc\u6c0f\u66ff\u6362\u539f\u5219\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def print_area(shape):<\/p>\n<p>    print(f&quot;Area of {shape.name}: {shape.area()}&quot;)<\/p>\n<p>shape = Rectangle(&quot;Rectangle&quot;, 5, 10)<\/p>\n<p>print_area(shape)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<strong>\u901a\u8fc7\u5c06Rectangle\u7c7b\u7684\u5b9e\u4f8b\u4f20\u9012\u7ed9print_area\u51fd\u6570\uff0c\u9075\u5faa\u4e86\u91cc\u6c0f\u66ff\u6362\u539f\u5219<\/strong>\u3002<\/p>\n<\/p>\n<p><h4>4. \u63a5\u53e3\u9694\u79bb\u539f\u5219<\/h4>\n<\/p>\n<p><p>\u63a5\u53e3\u9694\u79bb\u539f\u5219\u8981\u6c42\u7c7b\u5e94\u5f53\u53ea\u4f9d\u8d56\u4e8e\u5b83\u5b9e\u9645\u9700\u8981\u7684\u63a5\u53e3\uff0c\u4ece\u800c\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u4f9d\u8d56\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u9075\u5faa\u63a5\u53e3\u9694\u79bb\u539f\u5219\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class Shape:<\/p>\n<p>    def __init__(self, name):<\/p>\n<p>        self.name = name<\/p>\n<p>    def area(self):<\/p>\n<p>        pass<\/p>\n<p>    def perimeter(self):<\/p>\n<p>        pass<\/p>\n<p>class Drawable:<\/p>\n<p>    def draw(self):<\/p>\n<p>        pass<\/p>\n<p>class Rectangle(Shape, Drawable):<\/p>\n<p>    def __init__(self, name, width, height):<\/p>\n<p>        super().__init__(name)<\/p>\n<p>        self.width = width<\/p>\n<p>        self.height = height<\/p>\n<p>    def area(self):<\/p>\n<p>        return self.width * self.height<\/p>\n<p>    def perimeter(self):<\/p>\n<p>        return 2 * (self.width + self.height)<\/p>\n<p>    def draw(self):<\/p>\n<p>        print(f&quot;Drawing {self.name}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<strong>Rectangle\u7c7b\u5b9e\u73b0\u4e86Shape\u7c7b\u548cDrawable\u63a5\u53e3\uff0c\u907f\u514d\u4e86\u4e0d\u5fc5\u8981\u7684\u4f9d\u8d56<\/strong>\u3002<\/p>\n<\/p>\n<p><h4>5. \u4f9d\u8d56\u5012\u8f6c\u539f\u5219<\/h4>\n<\/p>\n<p><p>\u4f9d\u8d56\u5012\u8f6c\u539f\u5219\u8981\u6c42\u9ad8\u5c42\u6a21\u5757\u4e0d\u5e94\u4f9d\u8d56\u4e8e\u4f4e\u5c42\u6a21\u5757\uff0c\u4e8c\u8005\u90fd\u5e94\u4f9d\u8d56\u4e8e\u62bd\u8c61\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u9075\u5faa\u4f9d\u8d56\u5012\u8f6c\u539f\u5219\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class Shape:<\/p>\n<p>    def area(self):<\/p>\n<p>        pass<\/p>\n<p>class Rectangle(Shape):<\/p>\n<p>    def __init__(self, width, height):<\/p>\n<p>        self.width = width<\/p>\n<p>        self.height = height<\/p>\n<p>    def area(self):<\/p>\n<p>        return self.width * self.height<\/p>\n<p>class ShapePrinter:<\/p>\n<p>    def print_area(self, shape):<\/p>\n<p>        print(f&quot;Area: {shape.area()}&quot;)<\/p>\n<p>shape = Rectangle(5, 10)<\/p>\n<p>printer = ShapePrinter()<\/p>\n<p>printer.print_area(shape)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<strong>ShapePrinter\u7c7b\u4f9d\u8d56\u4e8eShape\u7c7b\u7684\u62bd\u8c61\uff0c\u800c\u4e0d\u662f\u5177\u4f53\u7684Rectangle\u7c7b\uff0c\u4ece\u800c\u9075\u5faa\u4e86\u4f9d\u8d56\u5012\u8f6c\u539f\u5219<\/strong>\u3002<\/p>\n<\/p>\n<p><h3>\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5b9a\u4e49\u4e00\u4e2ashape\u7c7b\u662fPython\u4e2d\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u7684\u4e00\u4e2a\u57fa\u672c\u793a\u4f8b\uff0c\u901a\u8fc7\u7c7b\u548c\u5bf9\u8c61\u3001\u7ee7\u627f\u4e0e\u591a\u6001\u3001\u5c5e\u6027\u4e0e\u65b9\u6cd5\u4ee5\u53ca\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u8bbe\u8ba1\u539f\u5219\u7b49\u6280\u672f\uff0c\u53ef\u4ee5\u521b\u5efa\u529f\u80fd\u5f3a\u5927\u4e14\u6613\u4e8e\u7ef4\u62a4\u7684\u4ee3\u7801\u3002\u5e0c\u671b\u672c\u6587\u5bf9\u60a8\u5728Python\u4e2d\u5b9a\u4e49shape\u7c7b\u6709\u6240\u5e2e\u52a9\u3002\u5982\u679c\u60a8\u6709\u4efb\u4f55\u95ee\u9898\u6216\u9700\u8981\u8fdb\u4e00\u6b65\u7684\u5e2e\u52a9\uff0c\u8bf7\u968f\u65f6\u8054\u7cfb\u6211\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u521b\u5efa\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684shape\u7c7b\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u521b\u5efa\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684shape\u7c7b\u53ef\u4ee5\u901a\u8fc7\u5b9a\u4e49\u4e00\u4e2a\u7c7b\u5e76\u5728\u5176\u4e2d\u6dfb\u52a0\u5c5e\u6027\u548c\u65b9\u6cd5\u6765\u5b9e\u73b0\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u57fa\u672c\u7684shape\u7c7b\uff0c\u5305\u542b\u5f62\u72b6\u7684\u540d\u79f0\u548c\u8ba1\u7b97\u9762\u79ef\u7684\u65b9\u6cd5\u3002\u4f7f\u7528\u6784\u9020\u51fd\u6570<code>__init__<\/code>\u6765\u521d\u59cb\u5316\u5c5e\u6027\uff0c\u5b9a\u4e49\u5176\u4ed6\u65b9\u6cd5\u6765\u8fdb\u884c\u8ba1\u7b97\u3002<\/p>\n<p><strong>\u8fd9\u4e2ashape\u7c7b\u53ef\u4ee5\u5305\u542b\u54ea\u4e9b\u5c5e\u6027\u548c\u65b9\u6cd5\uff1f<\/strong><br \/>shape\u7c7b\u53ef\u4ee5\u5305\u542b\u591a\u4e2a\u5c5e\u6027\uff0c\u4f8b\u5982\u5f62\u72b6\u7684\u540d\u79f0\u3001\u8fb9\u957f\u3001\u534a\u5f84\u7b49\u3002\u5e38\u89c1\u7684\u65b9\u6cd5\u5305\u62ec\u8ba1\u7b97\u9762\u79ef\u3001\u5468\u957f\u548c\u663e\u793a\u5f62\u72b6\u4fe1\u606f\u7b49\u3002\u53ef\u4ee5\u6839\u636e\u9700\u8981\u6269\u5c55\u7c7b\uff0c\u6dfb\u52a0\u66f4\u591a\u7684\u5177\u4f53\u5f62\u72b6\u7c7b\uff08\u5982\u5706\u5f62\u3001\u77e9\u5f62\u7b49\uff09\uff0c\u5e76\u5728\u8fd9\u4e9b\u7c7b\u4e2d\u91cd\u5199\u9762\u79ef\u8ba1\u7b97\u65b9\u6cd5\uff0c\u4ee5\u5b9e\u73b0\u591a\u6001\u6027\u3002<\/p>\n<p><strong>\u5982\u4f55\u5b9e\u73b0\u591a\u6001\u6027\u4ee5\u652f\u6301\u4e0d\u540c\u7684\u5f62\u72b6\uff1f<\/strong><br \/>\u901a\u8fc7\u7ee7\u627f\uff0c\u53ef\u4ee5\u521b\u5efa\u591a\u4e2a\u5b50\u7c7b\uff0c\u4f8b\u5982Circle\u3001Rectangle\u7b49\uff0c\u6bcf\u4e2a\u5b50\u7c7b\u53ef\u4ee5\u5b9e\u73b0\u81ea\u5df1\u7684\u9762\u79ef\u8ba1\u7b97\u65b9\u6cd5\u3002\u4f7f\u7528\u7236\u7c7b\u7684\u901a\u7528\u63a5\u53e3\uff0c\u8c03\u7528\u5b50\u7c7b\u7684\u65b9\u6cd5\uff0c\u8fd9\u6837\u5c31\u80fd\u5b9e\u73b0\u591a\u6001\u6027\u3002\u786e\u4fdd\u6bcf\u4e2a\u5b50\u7c7b\u90fd\u6709\u5176\u7279\u5b9a\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\uff0c\u540c\u65f6\u53ef\u4ee5\u91cd\u7528\u7236\u7c7b\u7684\u4ee3\u7801\uff0c\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u7ef4\u62a4\u6027\u548c\u53ef\u8bfb\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u5b9a\u4e49\u4e00\u4e2ashape\u7c7b\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528\u7c7b\u548c\u5bf9\u8c61\u3001\u7ee7\u627f\u4e0e\u591a\u6001\u3001\u5c5e\u6027\u4e0e\u65b9\u6cd5\u3001\u4ee5\u53ca\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u7684\u8bbe\u8ba1\u539f\u5219\u7b49 [&hellip;]","protected":false},"author":3,"featured_media":1041842,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1041836"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1041836"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1041836\/revisions"}],"predecessor-version":[{"id":1041845,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1041836\/revisions\/1041845"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1041842"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1041836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1041836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1041836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}