{"id":336,"date":"2025-10-10T15:30:46","date_gmt":"2025-10-10T07:30:46","guid":{"rendered":"http:\/\/www.pyteam.cn\/?p=336"},"modified":"2025-10-10T15:30:46","modified_gmt":"2025-10-10T07:30:46","slug":"%e5%bd%a9%e8%99%b9%e8%9e%ba%e6%97%8b-13-5","status":"publish","type":"post","link":"http:\/\/www.pyteam.cn\/index.php\/2025\/10\/10\/%e5%bd%a9%e8%99%b9%e8%9e%ba%e6%97%8b-13-5\/","title":{"rendered":"\u5f69\u8679\u87ba\u65cb  13.5"},"content":{"rendered":"\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:clamp(18px, 1.125rem, 27px);font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#90A4AE;--cbp-line-number-width:calc(2 * 0.6 * 1.125rem);line-height:clamp(26px, 1.625rem, 39px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#ededed;color:#8198a3\">Python<\/span><span role=\"button\" tabindex=\"0\" style=\"color:#90A4AE;display:none\" aria-label=\"\u590d\u5236\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>import turtle as t\nimport math\n\npen = t.Turtle()\npen.speed(0)\nt.bgcolor(\"black\")  # \u8bbe\u7f6e\u9ed1\u8272\u80cc\u666f\npen.pensize(2)\n\n# \u7ed8\u5236\u5f69\u8679\u87ba\u65cb\nfor i in range(200):  # \u7ed8\u5236200\u4e2a\u4e09\u89d2\u5f62\n    # \u989c\u8272\u6e10\u53d8\uff08\u4ece\u7ea2\u8272\u5230\u7d2b\u8272\uff09\n    hue = i \/ 200 * 0.8  # \u63a7\u5236\u8272\u76f8\u53d8\u5316\u8303\u56f4\n    pen.color(t.hsv_to_rgb(hue, 1.0, 1.0))\n    \n    # \u7ed8\u5236\u4e00\u4e2a\u4e09\u89d2\u5f62\n    for j in range(3):\n        pen.forward(i * 0.5)  # \u8fb9\u957f\u9010\u6e10\u589e\u52a0\n        pen.left(120)\n    \n    pen.left(11)  # \u6bcf\u6b21\u65cb\u8f6c11\u5ea6\n\nt.done()<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-lighter\" style=\"background-color: #FAFAFA\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #39ADB5; font-style: italic\">import<\/span><span style=\"color: #90A4AE\"> turtle <\/span><span style=\"color: #39ADB5; font-style: italic\">as<\/span><span style=\"color: #90A4AE\"> t<\/span><\/span>\n<span class=\"line\"><span style=\"color: #39ADB5; font-style: italic\">import<\/span><span style=\"color: #90A4AE\"> math<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">pen <\/span><span style=\"color: #39ADB5\">=<\/span><span style=\"color: #90A4AE\"> t<\/span><span style=\"color: #39ADB5\">.<\/span><span style=\"color: #6182B8\">Turtle<\/span><span style=\"color: #39ADB5\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">pen<\/span><span style=\"color: #39ADB5\">.<\/span><span style=\"color: #6182B8\">speed<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #F76D47\">0<\/span><span style=\"color: #39ADB5\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">t<\/span><span style=\"color: #39ADB5\">.<\/span><span style=\"color: #6182B8\">bgcolor<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #39ADB5\">&quot;<\/span><span style=\"color: #91B859\">black<\/span><span style=\"color: #39ADB5\">&quot;<\/span><span style=\"color: #39ADB5\">)<\/span><span style=\"color: #90A4AE\">  <\/span><span style=\"color: #90A4AE; font-style: italic\"># \u8bbe\u7f6e\u9ed1\u8272\u80cc\u666f<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">pen<\/span><span style=\"color: #39ADB5\">.<\/span><span style=\"color: #6182B8\">pensize<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #F76D47\">2<\/span><span style=\"color: #39ADB5\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE; font-style: italic\"># \u7ed8\u5236\u5f69\u8679\u87ba\u65cb<\/span><\/span>\n<span class=\"line\"><span style=\"color: #39ADB5; font-style: italic\">for<\/span><span style=\"color: #90A4AE\"> i <\/span><span style=\"color: #39ADB5; font-style: italic\">in<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #6182B8\">range<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #F76D47\">200<\/span><span style=\"color: #39ADB5\">):<\/span><span style=\"color: #90A4AE\">  <\/span><span style=\"color: #90A4AE; font-style: italic\"># \u7ed8\u5236200\u4e2a\u4e09\u89d2\u5f62<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    <\/span><span style=\"color: #90A4AE; font-style: italic\"># \u989c\u8272\u6e10\u53d8\uff08\u4ece\u7ea2\u8272\u5230\u7d2b\u8272\uff09<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    hue <\/span><span style=\"color: #39ADB5\">=<\/span><span style=\"color: #90A4AE\"> i <\/span><span style=\"color: #39ADB5\">\/<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #F76D47\">200<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #39ADB5\">*<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #F76D47\">0.8<\/span><span style=\"color: #90A4AE\">  <\/span><span style=\"color: #90A4AE; font-style: italic\"># \u63a7\u5236\u8272\u76f8\u53d8\u5316\u8303\u56f4<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    pen<\/span><span style=\"color: #39ADB5\">.<\/span><span style=\"color: #6182B8\">color<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #6182B8\">t<\/span><span style=\"color: #39ADB5\">.<\/span><span style=\"color: #6182B8\">hsv_to_rgb<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #6182B8\">hue<\/span><span style=\"color: #39ADB5\">,<\/span><span style=\"color: #6182B8\"> <\/span><span style=\"color: #F76D47\">1.0<\/span><span style=\"color: #39ADB5\">,<\/span><span style=\"color: #6182B8\"> <\/span><span style=\"color: #F76D47\">1.0<\/span><span style=\"color: #39ADB5\">))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    <\/span><span style=\"color: #90A4AE; font-style: italic\"># \u7ed8\u5236\u4e00\u4e2a\u4e09\u89d2\u5f62<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    <\/span><span style=\"color: #39ADB5; font-style: italic\">for<\/span><span style=\"color: #90A4AE\"> j <\/span><span style=\"color: #39ADB5; font-style: italic\">in<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #6182B8\">range<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #F76D47\">3<\/span><span style=\"color: #39ADB5\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">        pen<\/span><span style=\"color: #39ADB5\">.<\/span><span style=\"color: #6182B8\">forward<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #6182B8\">i <\/span><span style=\"color: #39ADB5\">*<\/span><span style=\"color: #6182B8\"> <\/span><span style=\"color: #F76D47\">0.5<\/span><span style=\"color: #39ADB5\">)<\/span><span style=\"color: #90A4AE\">  <\/span><span style=\"color: #90A4AE; font-style: italic\"># \u8fb9\u957f\u9010\u6e10\u589e\u52a0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">        pen<\/span><span style=\"color: #39ADB5\">.<\/span><span style=\"color: #6182B8\">left<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #F76D47\">120<\/span><span style=\"color: #39ADB5\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    pen<\/span><span style=\"color: #39ADB5\">.<\/span><span style=\"color: #6182B8\">left<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #F76D47\">11<\/span><span style=\"color: #39ADB5\">)<\/span><span style=\"color: #90A4AE\">  <\/span><span style=\"color: #90A4AE; font-style: italic\"># \u6bcf\u6b21\u65cb\u8f6c11\u5ea6<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">t<\/span><span style=\"color: #39ADB5\">.<\/span><span style=\"color: #6182B8\">done<\/span><span style=\"color: #39ADB5\">()<\/span><\/span><\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":88,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,5],"tags":[],"class_list":["post-336","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-22","category-5"],"views":147,"_links":{"self":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/comments?post=336"}],"version-history":[{"count":1,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/336\/revisions"}],"predecessor-version":[{"id":337,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/336\/revisions\/337"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/media\/88"}],"wp:attachment":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/media?parent=336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/categories?post=336"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/tags?post=336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}