{"id":764,"date":"2022-03-06T16:44:21","date_gmt":"2022-03-06T08:44:21","guid":{"rendered":"https:\/\/huiyu1688.top\/?p=764"},"modified":"2022-03-06T17:25:50","modified_gmt":"2022-03-06T09:25:50","slug":"%e7%94%a8python%e5%ae%9e%e7%8e%b0%e6%b5%b7%e9%be%9f%e7%bb%98%e5%9b%be%ef%bc%88%e7%bb%98%e5%88%b6%e5%86%ac%e5%a5%a5%e4%bc%9a%e5%90%89%e7%a5%a5%e7%89%a9-%e5%86%b0%e7%a4%85%e7%a4%85%ef%bc%89","status":"publish","type":"post","link":"https:\/\/hy68.top\/index.php\/2022\/03\/06\/764\/","title":{"rendered":"python\u6d77\u9f9f\u7ed8\u56fe\uff08\u7ed8\u5236\u51ac\u5965\u4f1a\u5409\u7965\u7269-\u51b0\u7905\u7905\uff09"},"content":{"rendered":"\n<figure class=\"wp-block-pullquote\"><blockquote><p>Turtle\u5e93\u662fPython\u8bed\u8a00\u4e2d\u4e00\u4e2a\u5f88\u6d41\u884c\u7684\u7ed8\u5236\u56fe\u50cf\u7684\u51fd\u6570\u5e93\uff0c\u60f3\u8c61\u4e00\u4e2a\u5c0f\u4e4c\u9f9f\uff0c\u5728\u4e00\u4e2a\u6a2a\u8f74\u4e3ax\u3001\u7eb5\u8f74\u4e3ay\u7684\u5750\u6807\u7cfb\u539f\u70b9\uff0c(0,0)\u4f4d\u7f6e\u5f00\u59cb\uff0c\u5b83\u6839\u636e\u4e00\u7ec4\u51fd\u6570\u6307\u4ee4\u7684\u63a7\u5236\uff0c\u5728\u8fd9\u4e2a\u5e73\u9762\u5750\u6807\u7cfb\u4e2d\u79fb\u52a8\uff0c\u4ece\u800c\u5728\u5b83\u722c\u884c\u7684\u8def\u5f84\u4e0a\u7ed8\u5236\u4e86\u56fe\u5f62\u3002<br>\u2003 \u2003<\/p><\/blockquote><\/figure>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-2 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-1 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\">\n<ul class=\"has-cyan-bluish-gray-background-color has-background\"><li><strong><u><strong>\u6d77\u9f9f\u7ed8\u56fe\u6cd5\u5e38\u7528\u51fd\u6570\uff1a<\/strong><\/u><\/strong><\/li><li>\u8981\u4f7f\u7528\u6d77\u9f9f\u7ed8\u56fe\uff0c\u9700\u8981\u8c03\u7528turtle\u5e93\uff0c\u8bed\u6cd5import turtle\uff0c\u5f15\u5165\u7ed8\u56fe\u5e93<\/li><li>\u8bbe\u7f6e\u7a97\u4f53\u6807\u9898&nbsp;&nbsp;title(&#8220;\u51b0\u7905\u7905&#8221;)<\/li><li>\u8bbe\u7f6e\u7a97\u4f53\u5927\u5c0f\u548c\u4f4d\u7f6e&nbsp;setup(1200, 800, 200, 200)<\/li><li>\u8bbe\u7f6e\u6d77\u9f9f\u7ed8\u56fe\u901f\u5ea6&nbsp;speed(3)<\/li><li>\u5207\u6362RGB\u8272\u5f69\u6a21\u5f0f 255:\u6574\u6570\u6a21\u5f0f&nbsp;&nbsp;colormode(255)<\/li><li>\u62ac\u7b14 penup()<\/li><li>\u79fb\u5230\u5750\u6807\u5904 goto()<\/li><li>\u843d\u7b14 pendown()&nbsp;<\/li><li>\u8bbe\u7f6e\u753b\u7b14\u989c\u8272 pencolor(&#8220;brown&#8221;)<\/li><li>\u8bbe\u7f6e\u753b\u7b14\u5bbd\u5ea6 pensize()<\/li><li>\u524d\u8fdb\uff1aforward(n)<\/li><li>\u5de6\u8f6c\u5f2f\uff1aleft(n)<\/li><li>\u53f3\u8f6c\u5f2f\uff1aright(n)<\/li><li>\u76f4\u63a5\u5199\uff1awrite(n)<\/li><li>\u7a97\u4f53\u6682\u505c\uff1adone()<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"537\" height=\"578\" src=\"https:\/\/huiyu1688.top\/wp-content\/uploads\/2022\/03\/bdd220306.png\" alt=\"\" class=\"wp-image-768\" srcset=\"https:\/\/hy68.top\/wp-content\/uploads\/2022\/03\/bdd220306.png 537w, https:\/\/hy68.top\/wp-content\/uploads\/2022\/03\/bdd220306-279x300.png 279w\" sizes=\"(max-width: 537px) 100vw, 537px\" \/><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">\u4f7f\u7528\u6d77\u9f9f\u753b\u56fe\u7ed8\u5236\u51b0\u7905\u7905\u4ee3\u7801\uff1a<\/h3>\n\n\n\n<pre class=\"wp-block-code has-background\" style=\"background-color:#f1fef5\"><code>import turtle as hytt\n\ndef ttDraw(tt):\n    # \u5de6\u624b\n    tt.penup()\n    tt.goto(177, 112)\n    tt.pencolor(\"lightgray\")\n    tt.pensize(3)\n    tt.fillcolor(\"white\")\n    tt.begin_fill()\n    tt.pendown()\n    tt.setheading(80)\n    tt.circle(-45, 200)\n    tt.circle(-300, 23)\n    tt.end_fill()\n\n    # \u5de6\u624b\u5185\n    tt.penup()\n    tt.goto(182, 95)\n    tt.pencolor(\"black\")\n    tt.pensize(1)\n    tt.fillcolor(\"black\")\n    tt.begin_fill()\n    tt.setheading(95)\n    tt.pendown()\n    tt.circle(-37, 160)\n    tt.circle(-20, 50)\n    tt.circle(-200, 30)\n    tt.end_fill()\n    # \u8f6e\u5ed3\n    # \u5934\u9876\n    tt.penup()\n    tt.goto(-73, 230)\n    tt.pencolor(\"lightgray\")\n    tt.pensize(3)\n    tt.fillcolor(\"white\")\n    tt.begin_fill()\n    tt.pendown()\n    tt.setheading(20)\n    tt.circle(-250, 35)\n    # \u5de6\u8033\n    tt.setheading(50)\n    tt.circle(-42, 180)\n    # \u5de6\u4fa7\n    tt.setheading(-50)\n    tt.circle(-190, 30)\n    tt.circle(-320, 45)\n    # \u5de6\u817f\n    tt.circle(120, 30)\n    tt.circle(200, 12)\n    tt.circle(-18, 85)\n    tt.circle(-180, 23)\n    tt.circle(-20, 110)\n    tt.circle(15, 115)\n    tt.circle(100, 12)\n    # \u53f3\u817f\n    tt.circle(15, 120)\n    tt.circle(-15, 110)\n    tt.circle(-150, 30)\n    tt.circle(-15, 70)\n    tt.circle(-150, 10)\n    tt.circle(200, 35)\n    tt.circle(-150, 20)\n    # \u53f3\u624b\n    tt.setheading(-120)\n    tt.circle(50, 30)\n    tt.circle(-35, 200)\n    tt.circle(-300, 23)\n    # \u53f3\u4fa7\n    tt.setheading(86)\n    tt.circle(-300, 26)\n    # \u53f3\u8033\n    tt.setheading(122)\n    tt.circle(-53, 160)\n    tt.end_fill()\n\n    # \u53f3\u8033\u5185\n    tt.penup()\n    tt.goto(-130, 180)\n    tt.pencolor(\"black\")\n    tt.pensize(1)\n    tt.fillcolor(\"black\")\n    tt.begin_fill()\n    tt.pendown()\n    tt.setheading(120)\n    tt.circle(-28, 160)\n    tt.setheading(210)\n    tt.circle(150, 20)\n    tt.end_fill()\n\n    # \u5de6\u8033\u5185\n    tt.penup()\n    tt.goto(90, 230)\n    tt.setheading(40)\n    tt.begin_fill()\n    tt.pendown()\n    tt.circle(-30, 170)\n    tt.setheading(125)\n    tt.circle(150, 23)\n    tt.end_fill()\n\n    # \u53f3\u624b\u5185\n    tt.penup()\n    tt.goto(-180, -55)\n    tt.fillcolor(\"black\")\n    tt.begin_fill()\n    tt.setheading(-120)\n    tt.pendown()\n    tt.circle(50, 30)\n    tt.circle(-27, 200)\n    tt.circle(-300, 20)\n    tt.setheading(-90)\n    tt.circle(300, 14)\n    tt.end_fill()\n\n    # \u5de6\u817f\u5185\n    tt.penup()\n    tt.goto(108, -168)\n    tt.fillcolor(\"black\")\n    tt.begin_fill()\n    tt.pendown()\n    tt.setheading(-115)\n    tt.circle(110, 15)\n    tt.circle(200, 10)\n    tt.circle(-18, 80)\n    tt.circle(-180, 13)\n    tt.circle(-20, 90)\n    tt.circle(15, 60)\n    tt.setheading(42)\n    tt.circle(-200, 29)\n    tt.end_fill()\n    # \u53f3\u817f\u5185\n    tt.penup()\n    tt.goto(-38, -210)\n    tt.fillcolor(\"black\")\n    tt.begin_fill()\n    tt.pendown()\n    tt.setheading(-155)\n    tt.circle(15, 100)\n    tt.circle(-10, 110)\n    tt.circle(-100, 30)\n    tt.circle(-15, 65)\n    tt.circle(-100, 10)\n    tt.circle(200, 15)\n    tt.setheading(-14)\n    tt.circle(-200, 27)\n    tt.end_fill()\n\n    # \u53f3\u773c\n    # \u773c\u5708\n    tt.penup()\n    tt.goto(-64, 120)\n    tt.begin_fill()\n    tt.pendown()\n    tt.setheading(40)\n    tt.circle(-35, 152)\n    tt.circle(-100, 50)\n    tt.circle(-35, 130)\n    tt.circle(-100, 50)\n    tt.end_fill()\n    # \u773c\u73e0\n    tt.penup()\n    tt.goto(-47, 55)\n    tt.fillcolor(\"white\")\n    tt.begin_fill()\n    tt.pendown()\n    tt.setheading(0)\n    tt.circle(25, 360)\n    tt.end_fill()\n    tt.penup()\n    tt.goto(-45, 62)\n    tt.pencolor(\"darkslategray\")\n    tt.fillcolor(\"darkslategray\")\n    tt.begin_fill()\n    tt.pendown()\n    tt.setheading(0)\n    tt.circle(19, 360)\n    tt.end_fill()\n    tt.penup()\n    tt.goto(-45, 68)\n    tt.fillcolor(\"black\")\n    tt.begin_fill()\n    tt.pendown()\n    tt.setheading(0)\n    tt.circle(10, 360)\n    tt.end_fill()\n    tt.penup()\n    tt.goto(-47, 86)\n    tt.pencolor(\"white\")\n    tt.fillcolor(\"white\")\n    tt.begin_fill()\n    tt.pendown()\n    tt.setheading(0)\n    tt.circle(5, 360)\n    tt.end_fill()\n\n    # \u5de6\u773c\n    # \u773c\u5708\n    tt.penup()\n    tt.goto(51, 82)\n    tt.fillcolor(\"black\")\n    tt.begin_fill()\n    tt.pendown()\n    tt.setheading(120)\n    tt.circle(-32, 152)\n    tt.circle(-100, 55)\n    tt.circle(-25, 120)\n    tt.circle(-120, 45)\n    tt.end_fill()    \n    # \u773c\u73e0\n    tt.penup()\n    tt.goto(79, 60)\n    tt.fillcolor(\"white\")\n    tt.begin_fill()\n    tt.pendown()\n    tt.setheading(0)\n    tt.circle(24, 360)\n    tt.end_fill()\n    tt.penup()\n    tt.goto(79, 64)\n    tt.pencolor(\"darkslategray\")\n    tt.fillcolor(\"darkslategray\")\n    tt.begin_fill()\n    tt.pendown()\n    tt.setheading(0)\n    tt.circle(19, 360)\n    tt.end_fill()\n    tt.penup()\n    tt.goto(79, 70)\n    tt.fillcolor(\"black\")\n    tt.begin_fill()\n    tt.pendown()\n    tt.setheading(0)\n    tt.circle(10, 360)\n    tt.end_fill()\n    tt.penup()\n    tt.goto(79, 88)\n    tt.pencolor(\"white\")\n    tt.fillcolor(\"white\")\n    tt.begin_fill()\n    tt.pendown()\n    tt.setheading(0)\n    tt.circle(5, 360)\n    tt.end_fill()\n\n    # \u9f3b\u5b50\n    tt.penup()\n    tt.goto(37, 80)\n    tt.fillcolor(\"black\")\n    tt.begin_fill()\n    tt.pendown()\n    tt.circle(-8, 130)\n    tt.circle(-22, 100)\n    tt.circle(-8, 130)\n    tt.end_fill()\n\n    # \u5634\n    tt.penup()\n    tt.goto(-15, 48)\n    tt.setheading(-36)\n    tt.begin_fill()\n    tt.pendown()\n    tt.circle(60, 70)\n    tt.setheading(-132)\n    tt.circle(-45, 100)\n    tt.end_fill()\n\n    # \u5f69\u8679\u5708\n    tt.penup()\n    tt.goto(-135, 120)\n    tt.pensize(5)\n    tt.pencolor(\"cyan\")\n    tt.pendown()\n    tt.setheading(60)\n    tt.circle(-165, 150)\n    tt.circle(-130, 78)\n    tt.circle(-250, 30)\n    tt.circle(-138, 105)\n    tt.penup()\n    tt.goto(-131, 116)\n    tt.pencolor(\"slateblue\")\n    tt.pendown()\n    tt.setheading(60)\n    tt.circle(-160, 144)\n    tt.circle(-120, 78)\n    tt.circle(-242, 30)\n    tt.circle(-135, 105)\n    tt.penup()\n    tt.goto(-127, 112)\n    tt.pencolor(\"orangered\")\n    tt.pendown()\n    tt.setheading(60)\n    tt.circle(-155, 136)\n    tt.circle(-116, 86)\n    tt.circle(-220, 30)\n    tt.circle(-134, 103)\n    tt.penup()\n    tt.goto(-123, 108)\n    tt.pencolor(\"gold\")\n    tt.pendown()\n    tt.setheading(60)\n    tt.circle(-150, 136)\n    tt.circle(-104, 86)\n    tt.circle(-220, 30)\n    tt.circle(-126, 102)\n    tt.penup()\n    tt.goto(-120, 104)\n    tt.pencolor(\"greenyellow\")\n    tt.pendown()\n    tt.setheading(60)\n    tt.circle(-145, 136)\n    tt.circle(-90, 83)\n    tt.circle(-220, 30)\n    tt.circle(-120, 100)\n    tt.penup()\n\n    # \u7231\u5fc3\n    tt.penup()\n    tt.goto(220, 115)\n    tt.pencolor(\"brown\")\n    tt.pensize(1)\n    tt.fillcolor(\"brown\")\n    tt.begin_fill()\n    tt.pendown()\n    tt.setheading(36)\n    tt.circle(-8, 180)\n    tt.circle(-60, 24)\n    tt.setheading(110)\n    tt.circle(-60, 24)\n    tt.circle(-8, 180)\n    tt.end_fill()\n\n    # \u4e94\u73af\n    tt.penup()\n    tt.goto(-5, -170)\n    tt.pendown()\n    tt.pencolor(\"blue\")\n    tt.circle(6)\n    tt.penup()\n    tt.goto(10, -170)\n    tt.pendown()\n    tt.pencolor(\"black\")\n    tt.circle(6)\n    tt.penup()\n    tt.goto(25, -170)\n    tt.pendown()\n    tt.pencolor(\"brown\")\n    tt.circle(6)\n    tt.penup()\n    tt.goto(2, -175)\n    tt.pendown()\n    tt.pencolor(\"lightgoldenrod\")\n    tt.circle(6)\n    tt.penup()\n    tt.goto(16, -175)\n    tt.pendown()\n    tt.pencolor(\"green\")\n    tt.circle(6)\n    tt.penup()\n\n    tt.pencolor(\"black\")\n    tt.goto(-16, -160)\n    tt.write(\"BEIJING 2022\", font=('Arial', 10, 'bold italic'))\n    \n    #\u62ac\u7b14\n    tt.penup()\n    \ndef main():\n    #\u8bbe\u7f6e\u7a97\u4f53\u6807\u9898\n    hytt.title(\"\u51b0\u7905\u7905\")\n    #\u8bbe\u7f6e\u7a97\u4f53\u5927\u5c0f\u548c\u4f4d\u7f6e\n    hytt.setup(1200, 800, 200, 200)\n    #\u8bbe\u7f6e\u6d77\u9f9f\u7ed8\u56fe\u901f\u5ea6\n    hytt.speed(3)  #\"fastest\": 0 \u6700\u5feb \"fast\": 10 \u5feb\n    #\u9690\u85cf\u6d77\u9f9f\u526a\u5934\n    hytt.hideturtle()\n    #\u62ac\u7b14\n    hytt.penup()\n    #\u5207\u6362RGB\u8272\u5f69\u6a21\u5f0f 255:\u6574\u6570\u6a21\u5f0f\u5207\u6362RGB\u8272\u5f69\u6a21\u5f0f\n    hytt.colormode(255)\n    \n    #\u6d4b\u8bd5\u7a0b\u5e8f\n    ttDraw(hytt)\n    \n    hytt.done()\n\nif __name__ == \"__main__\":\n    main()<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div><\/div>\n<\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ee3\u7801\u8fd0\u884c\u5f55\u50cf\uff1a<\/h2>\n\n\n\n<figure class=\"wp-block-video\"><video controls src=\"https:\/\/huiyu1688.top\/wp-content\/uploads\/2022\/03\/kk-2022-03-06-16-28-47.mp4\"><\/video><figcaption>\u5728VScode\u4e2d\u8fd0\u884c\u51b0\u7905\u7905\u4ee3\u7801\u5f55\u50cf<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Turtle\u5e93\u662fPython\u8bed\u8a00\u4e2d\u4e00\u4e2a\u5f88\u6d41\u884c\u7684\u7ed8\u5236\u56fe\u50cf\u7684\u51fd\u6570\u5e93\uff0c\u60f3\u8c61\u4e00\u4e2a\u5c0f\u4e4c\u9f9f\uff0c\u5728\u4e00\u4e2a\u6a2a\u8f74\u4e3ax\u3001\u7eb5\u8f74\u4e3ay\u7684\u5750\u6807&hellip;<\/p>\n","protected":false},"author":1,"featured_media":772,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,8,6],"tags":[28,100,99],"_links":{"self":[{"href":"https:\/\/hy68.top\/index.php\/wp-json\/wp\/v2\/posts\/764"}],"collection":[{"href":"https:\/\/hy68.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hy68.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hy68.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hy68.top\/index.php\/wp-json\/wp\/v2\/comments?post=764"}],"version-history":[{"count":6,"href":"https:\/\/hy68.top\/index.php\/wp-json\/wp\/v2\/posts\/764\/revisions"}],"predecessor-version":[{"id":777,"href":"https:\/\/hy68.top\/index.php\/wp-json\/wp\/v2\/posts\/764\/revisions\/777"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hy68.top\/index.php\/wp-json\/wp\/v2\/media\/772"}],"wp:attachment":[{"href":"https:\/\/hy68.top\/index.php\/wp-json\/wp\/v2\/media?parent=764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hy68.top\/index.php\/wp-json\/wp\/v2\/categories?post=764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hy68.top\/index.php\/wp-json\/wp\/v2\/tags?post=764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}