{"id":979833,"date":"2024-12-27T06:49:40","date_gmt":"2024-12-26T22:49:40","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/979833.html"},"modified":"2024-12-27T06:49:42","modified_gmt":"2024-12-26T22:49:42","slug":"%e5%a6%82%e4%bd%95%e7%94%a8python%e7%94%bb%e5%8f%b6","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/979833.html","title":{"rendered":"\u5982\u4f55\u7528Python\u753b\u53f6"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24205502\/5e6c4893-c588-45ae-ac39-5014156c0b52.webp\" alt=\"\u5982\u4f55\u7528Python\u753b\u53f6\" \/><\/p>\n<p><p> <strong>\u7528Python\u753b\u53f6\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u4f7f\u7528\u4e0d\u540c\u7684\u5e93\u548c\u5de5\u5177\uff0c\u5982Matplotlib\u3001Turtle\u3001\u548cPillow\u7b49\u3002\u901a\u8fc7\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u3001\u638c\u63e1\u57fa\u672c\u7684\u7ed8\u56fe\u6280\u5de7\u3001\u719f\u6089\u989c\u8272\u548c\u5f62\u72b6\u7684\u642d\u914d\u3001\u4ee5\u53ca\u7406\u89e3\u81ea\u7136\u53f6\u5b50\u7684\u7ed3\u6784\uff0c\u53ef\u4ee5\u521b\u9020\u51fa\u903c\u771f\u7684\u53f6\u5b50\u56fe\u5f62\u3002\u4f7f\u7528Turtle\u5e93\u662f\u4e00\u4e2a\u7b80\u5355\u4e14\u76f4\u89c2\u7684\u9009\u62e9\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u7ed8\u56fe\u529f\u80fd\u548c\u6613\u4e8e\u7406\u89e3\u7684\u63a5\u53e3\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528Turtle\u5e93\u7ed8\u5236\u53f6\u5b50\u56fe\u5f62\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b9a\u4e49\u53f6\u5b50\u7684\u8f6e\u5ed3\u548c\u586b\u5145\u989c\u8272\u6765\u5b9e\u73b0\u903c\u771f\u7684\u6548\u679c\u3002\u9996\u5148\uff0c\u8bbe\u7f6e\u753b\u5e03\u548c\u753b\u7b14\u7684\u57fa\u672c\u5c5e\u6027\uff0c\u5982\u80cc\u666f\u989c\u8272\u548c\u7b14\u7684\u7c97\u7ec6\u3002\u7136\u540e\uff0c\u5229\u7528Turtle\u5e93\u7684\u7ed8\u56fe\u547d\u4ee4\uff0c\u5982\u524d\u8fdb\uff08forward\uff09\u3001\u5de6\u8f6c\uff08left\uff09\u548c\u53f3\u8f6c\uff08right\uff09\uff0c\u6765\u9010\u6b65\u7ed8\u5236\u53f6\u5b50\u7684\u8f6e\u5ed3\u3002\u7ed8\u5236\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u586b\u5145\u547d\u4ee4\u4e3a\u53f6\u5b50\u7740\u8272\uff0c\u4f7f\u5176\u66f4\u5177\u89c6\u89c9\u5438\u5f15\u529b\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Python\u4e2d\u7684\u4e0d\u540c\u5de5\u5177\u6765\u7ed8\u5236\u53f6\u5b50\u3002<\/p>\n<\/p>\n<h2><strong>\u4e00\u3001\u4f7f\u7528TURTLE\u5e93\u7ed8\u5236\u53f6\u5b50<\/strong><\/h2>\n<p><p>Turtle\u662fPython\u4e2d\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684\u7ed8\u56fe\u5e93\uff0c\u7279\u522b\u9002\u5408\u521d\u5b66\u8005\uff0c\u56e0\u4e3a\u5b83\u7684\u547d\u4ee4\u7b80\u5355\u4e14\u6613\u4e8e\u7406\u89e3\u3002\u901a\u8fc7Turtle\u5e93\uff0c\u4f60\u53ef\u4ee5\u7ed8\u5236\u5404\u79cd\u5f62\u72b6\u548c\u56fe\u6848\uff0c\u5305\u62ec\u53f6\u5b50\u3002<\/p>\n<\/p>\n<p><h2>1. Turtle\u5e93\u7684\u57fa\u672c\u8bbe\u7f6e<\/h2>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u4f7f\u7528Turtle\u5e93\u7ed8\u5236\u56fe\u5f62\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u57fa\u672c\u7684\u8bbe\u7f6e\u3002\u8fd9\u5305\u62ec\u5bfc\u5165Turtle\u6a21\u5757\u3001\u521d\u59cb\u5316\u753b\u5e03\u3001\u8bbe\u7f6e\u80cc\u666f\u989c\u8272\u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import turtle<\/p>\n<h2><strong>\u521d\u59cb\u5316\u753b\u5e03<\/strong><\/h2>\n<p>screen = turtle.Screen()<\/p>\n<p>screen.bgcolor(&quot;white&quot;)  # \u8bbe\u7f6e\u80cc\u666f\u989c\u8272\u4e3a\u767d\u8272<\/p>\n<h2><strong>\u521b\u5efa\u753b\u7b14\u5bf9\u8c61<\/strong><\/h2>\n<p>pen = turtle.Turtle()<\/p>\n<p>pen.color(&quot;green&quot;)  # \u8bbe\u7f6e\u753b\u7b14\u989c\u8272\u4e3a\u7eff\u8272<\/p>\n<p>pen.speed(1)  # \u8bbe\u7f6e\u753b\u7b14\u901f\u5ea6<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165\u4e86Turtle\u6a21\u5757\uff0c\u7136\u540e\u521b\u5efa\u4e86\u4e00\u4e2a\u753b\u5e03\u5bf9\u8c61\uff0c\u5e76\u8bbe\u7f6e\u4e86\u80cc\u666f\u989c\u8272\u4e3a\u767d\u8272\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u753b\u7b14\u5bf9\u8c61\uff0c\u5e76\u5c06\u5176\u989c\u8272\u8bbe\u7f6e\u4e3a\u7eff\u8272\uff0c\u8fd9\u6837\u7ed8\u5236\u7684\u56fe\u5f62\u5c31\u4f1a\u5448\u73b0\u7eff\u8272\u7684\u6548\u679c\u3002<\/p>\n<\/p>\n<p><h2>2. \u7ed8\u5236\u53f6\u5b50\u7684\u8f6e\u5ed3<\/h2>\n<\/p>\n<p><p>\u4e3a\u4e86\u7ed8\u5236\u4e00\u4e2a\u7b80\u5355\u7684\u53f6\u5b50\u5f62\u72b6\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528Turtle\u5e93\u4e2d\u7684\u57fa\u672c\u7ed8\u56fe\u547d\u4ee4\u6765\u63a7\u5236\u753b\u7b14\u7684\u79fb\u52a8\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u7ed8\u5236\u53f6\u5b50\u7684\u5de6\u4fa7<\/p>\n<p>pen.begin_fill()  # \u5f00\u59cb\u586b\u5145\u989c\u8272<\/p>\n<p>pen.forward(100)  # \u5411\u524d\u79fb\u52a8100\u50cf\u7d20<\/p>\n<p>pen.left(45)      # \u5de6\u8f6c45\u5ea6<\/p>\n<p>pen.forward(50)   # \u5411\u524d\u79fb\u52a850\u50cf\u7d20<\/p>\n<p>pen.left(90)      # \u5de6\u8f6c90\u5ea6<\/p>\n<p>pen.forward(50)   # \u5411\u524d\u79fb\u52a850\u50cf\u7d20<\/p>\n<p>pen.left(45)      # \u5de6\u8f6c45\u5ea6<\/p>\n<p>pen.forward(100)  # \u5411\u524d\u79fb\u52a8100\u50cf\u7d20<\/p>\n<h2><strong>\u7ed8\u5236\u53f6\u5b50\u7684\u53f3\u4fa7<\/strong><\/h2>\n<p>pen.left(45)      # \u5de6\u8f6c45\u5ea6<\/p>\n<p>pen.forward(100)  # \u5411\u524d\u79fb\u52a8100\u50cf\u7d20<\/p>\n<p>pen.left(45)      # \u5de6\u8f6c45\u5ea6<\/p>\n<p>pen.forward(50)   # \u5411\u524d\u79fb\u52a850\u50cf\u7d20<\/p>\n<p>pen.left(90)      # \u5de6\u8f6c90\u5ea6<\/p>\n<p>pen.forward(50)   # \u5411\u524d\u79fb\u52a850\u50cf\u7d20<\/p>\n<p>pen.left(45)      # \u5de6\u8f6c45\u5ea6<\/p>\n<p>pen.forward(100)  # \u5411\u524d\u79fb\u52a8100\u50cf\u7d20<\/p>\n<p>pen.end_fill()    # \u7ed3\u675f\u586b\u5145\u989c\u8272<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4ee5\u4e0a\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u901a\u8fc7\u4e00\u7cfb\u5217\u7684\u79fb\u52a8\u548c\u65cb\u8f6c\u547d\u4ee4\u7ed8\u5236\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u53f6\u5b50\u8f6e\u5ed3\u3002\u5728\u7ed8\u5236\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>begin_fill()<\/code>\u548c<code>end_fill()<\/code>\u547d\u4ee4\u6765\u586b\u5145\u53f6\u5b50\u7684\u989c\u8272\uff0c\u4f7f\u5176\u66f4\u5177\u89c6\u89c9\u5438\u5f15\u529b\u3002<\/p>\n<\/p>\n<h2><strong>\u4e8c\u3001\u4f7f\u7528MATPLOTLIB\u5e93\u7ed8\u5236\u53f6\u5b50<\/strong><\/h2>\n<p><p>\u9664\u4e86Turtle\u5e93\u5916\uff0cMatplotlib\u4e5f\u662fPython\u4e2d\u4e00\u4e2a\u975e\u5e38\u5f3a\u5927\u7684\u7ed8\u56fe\u5e93\uff0c\u901a\u5e38\u7528\u4e8e\u6570\u636e\u53ef\u89c6\u5316\uff0c\u4f46\u4e5f\u53ef\u4ee5\u7528\u6765\u7ed8\u5236\u590d\u6742\u7684\u56fe\u5f62\uff0c\u5305\u62ec\u53f6\u5b50\u3002<\/p>\n<\/p>\n<p><h2>1. Matplotlib\u5e93\u7684\u57fa\u672c\u8bbe\u7f6e<\/h2>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Matplotlib\u7ed8\u5236\u56fe\u5f62\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u57fa\u672c\u7684\u8bbe\u7f6e\uff0c\u5305\u62ec\u5bfc\u5165Matplotlib\u6a21\u5757\u3001\u521d\u59cb\u5316\u56fe\u5f62\u5bf9\u8c61\u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u56fe\u5f62\u5bf9\u8c61<\/strong><\/h2>\n<p>fig, ax = plt.subplots()<\/p>\n<p>ax.set_aspect(&#39;equal&#39;)  # \u8bbe\u7f6e\u5750\u6807\u8f74\u6bd4\u4f8b\u76f8\u7b49<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165\u4e86Matplotlib\u6a21\u5757\uff0c\u7136\u540e\u521b\u5efa\u4e86\u4e00\u4e2a\u56fe\u5f62\u5bf9\u8c61\uff0c\u5e76\u8bbe\u7f6e\u4e86\u5750\u6807\u8f74\u7684\u6bd4\u4f8b\u76f8\u7b49\uff0c\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u7ed8\u5236\u7684\u56fe\u5f62\u4e0d\u4f1a\u56e0\u4e3a\u5750\u6807\u8f74\u7684\u6bd4\u4f8b\u4e0d\u540c\u800c\u53d8\u5f62\u3002<\/p>\n<\/p>\n<p><h2>2. \u7ed8\u5236\u53f6\u5b50\u7684\u5f62\u72b6<\/h2>\n<\/p>\n<p><p>\u5728Matplotlib\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u591a\u8fb9\u5f62\u6765\u7ed8\u5236\u53f6\u5b50\u7684\u5f62\u72b6\u3002\u901a\u8fc7\u5b9a\u4e49\u591a\u8fb9\u5f62\u7684\u9876\u70b9\u5750\u6807\uff0c\u7136\u540e\u4f7f\u7528<code>Polygon<\/code>\u7c7b\u6765\u7ed8\u5236\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from matplotlib.patches import Polygon<\/p>\n<h2><strong>\u5b9a\u4e49\u53f6\u5b50\u7684\u9876\u70b9\u5750\u6807<\/strong><\/h2>\n<p>vertices = np.array([[0, 0], [2, 4], [4, 6], [6, 4], [8, 0], [4, -4]])<\/p>\n<h2><strong>\u521b\u5efa\u591a\u8fb9\u5f62\u5bf9\u8c61<\/strong><\/h2>\n<p>leaf = Polygon(vertices, closed=True, fill=True, color=&#39;green&#39;)<\/p>\n<h2><strong>\u6dfb\u52a0\u591a\u8fb9\u5f62\u5230\u56fe\u5f62\u4e2d<\/strong><\/h2>\n<p>ax.add_patch(leaf)<\/p>\n<h2><strong>\u8bbe\u7f6e\u5750\u6807\u8f74\u8303\u56f4<\/strong><\/h2>\n<p>ax.set_xlim(-1, 9)<\/p>\n<p>ax.set_ylim(-5, 7)<\/p>\n<h2><strong>\u663e\u793a\u56fe\u5f62<\/strong><\/h2>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4ee5\u4e0a\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u901a\u8fc7\u5b9a\u4e49\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u6765\u8868\u793a\u53f6\u5b50\u7684\u9876\u70b9\u5750\u6807\uff0c\u7136\u540e\u4f7f\u7528<code>Polygon<\/code>\u7c7b\u521b\u5efa\u591a\u8fb9\u5f62\u5bf9\u8c61\uff0c\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u56fe\u5f62\u4e2d\u3002\u6700\u540e\uff0c\u901a\u8fc7<code>show()<\/code>\u51fd\u6570\u663e\u793a\u7ed8\u5236\u7684\u56fe\u5f62\u3002<\/p>\n<\/p>\n<h2><strong>\u4e09\u3001\u4f7f\u7528PILLOW\u5e93\u7ed8\u5236\u53f6\u5b50<\/strong><\/h2>\n<p><p>Pillow\u662fPython\u4e2d\u4e00\u4e2a\u5f3a\u5927\u7684\u56fe\u50cf\u5904\u7406\u5e93\uff0c\u53ef\u4ee5\u7528\u6765\u521b\u5efa\u548c\u7f16\u8f91\u56fe\u50cf\u3002\u901a\u8fc7Pillow\u5e93\uff0c\u4f60\u53ef\u4ee5\u751f\u6210\u4e0d\u540c\u5f62\u72b6\u548c\u989c\u8272\u7684\u53f6\u5b50\u56fe\u5f62\u3002<\/p>\n<\/p>\n<p><h2>1. Pillow\u5e93\u7684\u57fa\u672c\u8bbe\u7f6e<\/h2>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Pillow\u5e93\u7ed8\u5236\u56fe\u5f62\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u57fa\u672c\u7684\u8bbe\u7f6e\uff0c\u5305\u62ec\u5bfc\u5165Pillow\u6a21\u5757\u3001\u521b\u5efa\u56fe\u50cf\u5bf9\u8c61\u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from PIL import Image, ImageDraw<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u7a7a\u767d\u56fe\u50cf<\/strong><\/h2>\n<p>image = Image.new(&#39;RGB&#39;, (200, 200), &#39;white&#39;)<\/p>\n<h2><strong>\u521b\u5efa\u7ed8\u56fe\u5bf9\u8c61<\/strong><\/h2>\n<p>draw = ImageDraw.Draw(image)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165\u4e86Pillow\u6a21\u5757\uff0c\u7136\u540e\u521b\u5efa\u4e86\u4e00\u4e2a\u7a7a\u767d\u56fe\u50cf\uff0c\u5e76\u8bbe\u7f6e\u4e86\u80cc\u666f\u989c\u8272\u4e3a\u767d\u8272\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u7ed8\u56fe\u5bf9\u8c61\uff0c\u7528\u4e8e\u5728\u56fe\u50cf\u4e0a\u7ed8\u5236\u56fe\u5f62\u3002<\/p>\n<\/p>\n<p><h2>2. \u7ed8\u5236\u53f6\u5b50\u7684\u5f62\u72b6<\/h2>\n<\/p>\n<p><p>\u5728Pillow\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528<code>polygon<\/code>\u51fd\u6570\u6765\u7ed8\u5236\u591a\u8fb9\u5f62\u5f62\u72b6\u7684\u53f6\u5b50\u3002\u901a\u8fc7\u5b9a\u4e49\u591a\u8fb9\u5f62\u7684\u9876\u70b9\u5750\u6807\uff0c\u7136\u540e\u4f7f\u7528<code>polygon<\/code>\u51fd\u6570\u6765\u7ed8\u5236\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u53f6\u5b50\u7684\u9876\u70b9\u5750\u6807<\/p>\n<p>vertices = [(50, 100), (75, 150), (100, 175), (125, 150), (150, 100), (100, 50)]<\/p>\n<h2><strong>\u7ed8\u5236\u591a\u8fb9\u5f62\u53f6\u5b50<\/strong><\/h2>\n<p>draw.polygon(vertices, outline=&#39;green&#39;, fill=&#39;green&#39;)<\/p>\n<h2><strong>\u663e\u793a\u56fe\u50cf<\/strong><\/h2>\n<p>image.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4ee5\u4e0a\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u901a\u8fc7\u5b9a\u4e49\u4e00\u4e2a\u5217\u8868\u6765\u8868\u793a\u53f6\u5b50\u7684\u9876\u70b9\u5750\u6807\uff0c\u7136\u540e\u4f7f\u7528<code>polygon<\/code>\u51fd\u6570\u7ed8\u5236\u591a\u8fb9\u5f62\u5f62\u72b6\u7684\u53f6\u5b50\uff0c\u5e76\u8bbe\u7f6e\u5176\u8f6e\u5ed3\u548c\u586b\u5145\u989c\u8272\u4e3a\u7eff\u8272\u3002\u6700\u540e\uff0c\u901a\u8fc7<code>show()<\/code>\u51fd\u6570\u663e\u793a\u7ed8\u5236\u7684\u56fe\u50cf\u3002<\/p>\n<\/p>\n<h2><strong>\u56db\u3001\u7406\u89e3\u81ea\u7136\u53f6\u5b50\u7684\u7ed3\u6784<\/strong><\/h2>\n<p><p>\u5728\u7ed8\u5236\u53f6\u5b50\u65f6\uff0c\u7406\u89e3\u81ea\u7136\u53f6\u5b50\u7684\u7ed3\u6784\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u81ea\u7136\u754c\u4e2d\u7684\u53f6\u5b50\u5177\u6709\u591a\u6837\u7684\u5f62\u72b6\u548c\u7eb9\u7406\uff0c\u901a\u5e38\u7531\u53f6\u7247\u3001\u53f6\u8109\u548c\u53f6\u67c4\u7ec4\u6210\u3002<\/p>\n<\/p>\n<p><h2>1. \u53f6\u7247\u7684\u5f62\u72b6<\/h2>\n<\/p>\n<p><p>\u53f6\u7247\u662f\u53f6\u5b50\u7684\u4e3b\u8981\u90e8\u5206\uff0c\u901a\u5e38\u5448\u73b0\u6241\u5e73\u72b6\u3002\u4e0d\u540c\u690d\u7269\u7684\u53f6\u7247\u5f62\u72b6\u5404\u5f02\uff0c\u6709\u7684\u53f6\u7247\u5448\u692d\u5706\u5f62\uff0c\u6709\u7684\u5448\u5fc3\u5f62\u6216\u638c\u5f62\u3002\u5728\u7ed8\u5236\u53f6\u5b50\u65f6\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u9700\u8981\u9009\u62e9\u4e0d\u540c\u7684\u53f6\u7247\u5f62\u72b6\u3002<\/p>\n<\/p>\n<p><h2>2. \u53f6\u8109\u7684\u7eb9\u7406<\/h2>\n<\/p>\n<p><p>\u53f6\u8109\u662f\u53f6\u7247\u4e2d\u7ec6\u957f\u7684\u8109\u7edc\uff0c\u901a\u5e38\u8d1f\u8d23\u8f93\u9001\u6c34\u5206\u548c\u517b\u5206\u3002\u5728\u7ed8\u5236\u53f6\u5b50\u65f6\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u6dfb\u52a0\u7ec6\u7ebf\u6765\u8868\u793a\u53f6\u8109\u7684\u7eb9\u7406\uff0c\u4f7f\u53f6\u5b50\u770b\u8d77\u6765\u66f4\u52a0\u903c\u771f\u3002<\/p>\n<\/p>\n<p><h2>3. \u53f6\u67c4\u7684\u8fde\u63a5<\/h2>\n<\/p>\n<p><p>\u53f6\u67c4\u662f\u8fde\u63a5\u53f6\u7247\u548c\u830e\u7684\u90e8\u5206\uff0c\u901a\u5e38\u8f83\u7ec6\u3002\u5728\u7ed8\u5236\u53f6\u5b50\u65f6\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u6dfb\u52a0\u4e00\u6839\u7ebf\u6761\u6765\u8868\u793a\u53f6\u67c4\uff0c\u4f7f\u53f6\u5b50\u4e0e\u830e\u76f8\u8fde\u63a5\u3002<\/p>\n<\/p>\n<h2><strong>\u4e94\u3001\u603b\u7ed3\u4e0e\u5b9e\u8df5<\/strong><\/h2>\n<p><p>\u901a\u8fc7\u5b66\u4e60\u5982\u4f55\u4f7f\u7528Python\u7684\u4e0d\u540c\u5e93\u548c\u5de5\u5177\u7ed8\u5236\u53f6\u5b50\uff0c\u4f60\u53ef\u4ee5\u521b\u4f5c\u51fa\u4e30\u5bcc\u591a\u6837\u7684\u53f6\u5b50\u56fe\u5f62\u3002\u5728\u5b9e\u8df5\u4e2d\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u9700\u8981\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\uff0c\u5e76\u7ed3\u5408\u5bf9\u81ea\u7136\u53f6\u5b50\u7ed3\u6784\u7684\u7406\u89e3\uff0c\u521b\u9020\u51fa\u903c\u771f\u7684\u53f6\u5b50\u827a\u672f\u4f5c\u54c1\u3002<\/p>\n<\/p>\n<p><p>\u65e0\u8bba\u662f\u4f7f\u7528Turtle\u5e93\u7ed8\u5236\u7b80\u5355\u7684\u53f6\u5b50\u5f62\u72b6\uff0c\u8fd8\u662f\u4f7f\u7528Matplotlib\u548cPillow\u521b\u5efa\u590d\u6742\u7684\u53f6\u5b50\u56fe\u6848\uff0c\u90fd\u53ef\u4ee5\u5e2e\u52a9\u4f60\u63d0\u9ad8\u7ed8\u56fe\u6280\u80fd\uff0c\u5e76\u6fc0\u53d1\u521b\u4f5c\u7075\u611f\u3002\u5e0c\u671b\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u4f60\u80fd\u5728Python\u7ed8\u56fe\u7684\u65c5\u7a0b\u4e2d\u4e0d\u65ad\u63a2\u7d22\u548c\u8fdb\u6b65\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u7528Python\u7ed8\u5236\u53f6\u5b50\u7684\u5f62\u72b6\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u4f7f\u7528matplotlib\u5e93\u53ef\u4ee5\u8f7b\u677e\u7ed8\u5236\u53f6\u5b50\u7684\u5f62\u72b6\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u5b89\u88c5matplotlib\u5e93\u3002\u63a5\u7740\uff0c\u60a8\u53ef\u4ee5\u5b9a\u4e49\u53f6\u5b50\u7684\u6570\u5b66\u65b9\u7a0b\u6216\u4f7f\u7528\u7b80\u5355\u7684\u51e0\u4f55\u56fe\u5f62\u6765\u8868\u793a\u53f6\u5b50\u7684\u8f6e\u5ed3\u3002\u901a\u8fc7\u8c03\u6574\u5750\u6807\u3001\u989c\u8272\u548c\u7ebf\u6761\u6837\u5f0f\uff0c\u53ef\u4ee5\u5b9e\u73b0\u4e0d\u540c\u7684\u53f6\u5b50\u6548\u679c\u3002<\/p>\n<p><strong>\u7ed8\u5236\u53f6\u5b50\u65f6\u9700\u8981\u6ce8\u610f\u54ea\u4e9b\u7ec6\u8282\uff1f<\/strong><br \/>\u5728\u7ed8\u5236\u53f6\u5b50\u65f6\uff0c\u786e\u4fdd\u9009\u62e9\u5408\u9002\u7684\u989c\u8272\u548c\u5f62\u72b6\uff0c\u4ee5\u4f7f\u53f6\u5b50\u770b\u8d77\u6765\u81ea\u7136\u3002\u53ef\u4ee5\u4f7f\u7528\u6e10\u53d8\u8272\u6765\u589e\u52a0\u5c42\u6b21\u611f\uff0c\u6216\u8005\u6dfb\u52a0\u9634\u5f71\u6548\u679c\u6765\u589e\u5f3a\u7acb\u4f53\u611f\u3002\u6b64\u5916\uff0c\u8003\u8651\u4f7f\u7528\u4e0d\u540c\u7684\u7ed8\u56fe\u51fd\u6570\uff0c\u5982scatter\u6216fill\uff0c\u6765\u5b9e\u73b0\u591a\u6837\u5316\u7684\u89c6\u89c9\u6548\u679c\u3002<\/p>\n<p><strong>Python\u4e2d\u662f\u5426\u6709\u73b0\u6210\u7684\u5e93\u4e13\u95e8\u7528\u4e8e\u7ed8\u5236\u690d\u7269\u6216\u53f6\u5b50\uff1f<\/strong><br \/>\u662f\u7684\uff0c\u6709\u4e00\u4e9b\u4e13\u95e8\u7528\u4e8e\u7ed8\u5236\u690d\u7269\u548c\u53f6\u5b50\u7684Python\u5e93\uff0c\u4f8b\u5982Turtle\u548cPygame\u3002\u8fd9\u4e9b\u5e93\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u56fe\u5f62\u7ed8\u5236\u529f\u80fd\uff0c\u53ef\u4ee5\u5e2e\u52a9\u60a8\u66f4\u8f7b\u677e\u5730\u521b\u5efa\u590d\u6742\u7684\u690d\u7269\u5f62\u72b6\u3002\u6b64\u5916\uff0c\u4f7f\u7528\u8fd9\u4e9b\u5e93\u65f6\uff0c\u60a8\u53ef\u4ee5\u5229\u7528\u73b0\u6709\u7684\u51fd\u6570\u548c\u7c7b\uff0c\u5feb\u901f\u5b9e\u73b0\u5404\u79cd\u690d\u7269\u7684\u56fe\u6848\u548c\u6548\u679c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u7528Python\u753b\u53f6\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u4f7f\u7528\u4e0d\u540c\u7684\u5e93\u548c\u5de5\u5177\uff0c\u5982Matplotlib\u3001Turtle\u3001\u548cPillow\u7b49 [&hellip;]","protected":false},"author":3,"featured_media":979840,"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\/979833"}],"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=979833"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/979833\/revisions"}],"predecessor-version":[{"id":979843,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/979833\/revisions\/979843"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/979840"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=979833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=979833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=979833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}