{"id":72098,"date":"2026-02-04T21:56:57","date_gmt":"2026-02-04T13:56:57","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/72098.html"},"modified":"2026-02-04T21:56:57","modified_gmt":"2026-02-04T13:56:57","slug":"python-%e7%bb%98%e5%88%b6%e5%8a%a8%e6%80%81%e8%b7%b3%e5%8a%a8%e7%88%b1%e5%bf%83%ef%bd%9c%e6%83%85%e4%ba%ba%e8%8a%82%e4%b8%93%e5%b1%9e%e6%b5%aa%e6%bc%ab%e4%bb%a3%e7%a0%81%ef%bc%8c%e6%96%b0%e6%89%8b","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/72098.html","title":{"rendered":"Python \u7ed8\u5236\u52a8\u6001\u8df3\u52a8\u7231\u5fc3\uff5c\u60c5\u4eba\u8282\u4e13\u5c5e\u6d6a\u6f2b\u4ee3\u7801\uff0c\u65b0\u624b\u96f6\u57fa\u7840\u4e5f\u80fd\u4e0a\u624b"},"content":{"rendered":"<p>\u9a6c\u4e0a\u5c31\u662f\u60c5\u4eba\u8282&#xff0c;\u7a0b\u5e8f\u5458\u7684\u6d6a\u6f2b\u4ece\u4e00\u884c\u884c\u4ee3\u7801\u5f00\u59cb&#xff01;\u4eca\u5929\u5206\u4eab\u4e00\u6b3e\u7eaf Python \u5185\u7f6e\u5e93\u5b9e\u73b0\u7684\u52a8\u6001\u8df3\u52a8\u7231\u5fc3&#xff0c;\u65e0\u9700\u590d\u6742\u7b2c\u4e09\u65b9\u4f9d\u8d56&#xff0c;\u9ed1\u8272\u80cc\u666f\u642d\u914d\u7c92\u5b50\u5316\u7231\u5fc3&#xff0c;\u81ea\u5e26\u81ea\u7136\u7684\u8df3\u52a8\u8282\u594f\u548c\u67d4\u548c\u5149\u6655&#xff0c;\u65e2\u9002\u5408\u9001\u7ed9\u5fc3\u4eea\u7684\u4eba\u5236\u9020\u60ca\u559c&#xff0c;\u4e5f\u80fd\u4f5c\u4e3a Python \u57fa\u7840\u7ec3\u624b\u6848\u4f8b\u3002\u672c\u6587\u5168\u7a0b\u4fdd\u59c6\u7ea7\u6587\u672c\u89e3\u6790 &#043; \u4ee3\u7801\u6ce8\u91ca\u53cc\u4fdd\u969c&#xff0c;\u4ece\u73af\u5883\u642d\u5efa\u5230\u4ee3\u7801\u903b\u8f91\u9010\u5b57\u62c6\u89e3&#xff0c;\u7eaf\u65b0\u624b\u4e5f\u80fd\u8ddf\u7740\u4e00\u6b65\u6b65\u5b9e\u73b0&#xff0c;\u8f7b\u677e\u62ff\u634f\u7f16\u7a0b\u6d6a\u6f2b&#xff5e;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260204135652-698350242fd69.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u8fd9\u662f\u6700\u8fd1\u7c89\u4e1d\u79c1\u4fe1\u6c42\u8868\u767d\u4ee3\u7801\u7684\u804a\u5929\u8bb0\u5f55 \u2014\u2014 \u60c5\u4eba\u8282 \/ \u8fc7\u5e74\u60f3\u7ed9\u5fc3\u4eea\u7684\u4eba\u5236\u9020\u6d6a\u6f2b&#xff0c;\u7528\u4ee3\u7801\u505a\u4e00\u4efd\u4e13\u5c5e\u7231\u5fc3\u793c\u7269\u518d\u5408\u9002\u4e0d\u8fc7&#xff0c;\u5b89\u6392&#xff01;<\/p>\n<h2>\u4e00\u3001\u6548\u679c\u9884\u89c8<\/h2>\n<p>\u8fd0\u884c\u4ee3\u7801\u540e\u4f1a\u76f4\u63a5\u5f39\u51fa640\u00d7480\u7684\u72ec\u7acb\u56fe\u5f62\u7a97\u53e3&#xff0c;\u9ed1\u8272\u80cc\u666f\u642d\u914d\u7c92\u5b50\u5316\u7c89\u8272\u7231\u5fc3&#xff0c;\u5b9e\u73b0\u6c89\u6d78\u5f0f\u6d6a\u6f2b\u89c6\u89c9\u6548\u679c&#xff0c;\u6838\u5fc3\u6548\u679c\u5982\u4e0b&#xff1a;<\/p>\n<li>\u7231\u5fc3\u4ee5\u81ea\u7136\u7684\u5468\u671f\u6027\u8282\u594f\u8df3\u52a8&#xff0c;\u5b8c\u6210\u201c\u6536\u7f29-\u6269\u5f20-\u6536\u7f29\u201d\u7684\u5faa\u73af&#xff0c;\u6d41\u7545\u65e0\u5361\u987f&#xff1b;<\/li>\n<li>\u7231\u5fc3\u7531\u5927\u91cf\u7ec6\u817b\u7c92\u5b50\u6784\u6210&#xff0c;\u8f6e\u5ed3\u6e05\u6670\u3001\u5185\u90e8\u586b\u5145\u9971\u6ee1&#xff0c;\u8fb9\u7f18\u5e26\u6709\u8f7b\u5fae\u7c92\u5b50\u6269\u6563\u6548\u679c&#xff1b;<\/li>\n<li>\u7231\u5fc3\u5916\u56f4\u9644\u5e26\u52a8\u6001\u5149\u6655&#xff0c;\u5149\u6655\u7684\u5927\u5c0f\u3001\u7c92\u5b50\u6570\u91cf\u968f\u7231\u5fc3\u8df3\u52a8\u8282\u594f\u540c\u6b65\u53d8\u5316&#xff0c;\u6c1b\u56f4\u611f\u62c9\u6ee1&#xff1b;<\/li>\n<li>\u5168\u7a0b\u52a8\u6001\u6e32\u67d3&#xff0c;\u5bf9\u7535\u8111\u6027\u80fd\u65e0\u8981\u6c42&#xff0c;\u4f4e\u914d\u8bbe\u5907\u4e5f\u80fd\u6d41\u7545\u8fd0\u884c&#xff0c;\u5173\u95ed\u7a97\u53e3\u5373\u53ef\u505c\u6b62\u7a0b\u5e8f\u3002<\/li>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260204135653-698350259da6a.gif\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h2>\u4e8c\u3001\u73af\u5883\u51c6\u5907<\/h2>\n<p>\u672c\u6848\u4f8b\u57fa\u4e8ePython 3.8\u53ca\u4ee5\u4e0a\u7248\u672c\u5f00\u53d1&#xff0c;\u4ec5\u4f7f\u7528Python\u5185\u7f6e\u6807\u51c6\u5e93&#xff0c;\u65e0\u9700\u989d\u5916\u5b89\u88c5\u7b2c\u4e09\u65b9\u5305&#xff0c;\u6838\u5fc3\u9700\u51c6\u5907\u300cPython\u89e3\u91ca\u5668&#043;\u4ee3\u7801\u7f16\u8f91\u5668\u300d&#xff0c;\u5e76\u638c\u63e1\u57fa\u7840\u7684\u6a21\u5757\u5bfc\u5165\u65b9\u6cd5&#xff0c;\u4ee5\u4e0b\u662f\u4e00\u6b65\u4e0d\u843d\u7684\u8be6\u7ec6\u51c6\u5907\u6b65\u9aa4&#xff0c;\u96f6\u57fa\u7840\u4e5f\u80fd\u8f7b\u677e\u843d\u5730&#xff01;<\/p>\n<h3>2.1 \u5b89\u88c5Python\u89e3\u91ca\u5668<\/h3>\n<p>Python\u89e3\u91ca\u5668\u662f\u6267\u884cPython\u4ee3\u7801\u7684\u6838\u5fc3\u8f7d\u4f53&#xff0c;\u65e0\u89e3\u91ca\u5668\u4ee3\u7801\u65e0\u6cd5\u8fd0\u884c&#xff0c;\u63a8\u8350\u5b89\u88c53.8\/3.9\/3.10\u7248\u672c&#xff08;\u517c\u5bb9\u6027\u6700\u4f73&#xff0c;\u65e0\u7248\u672c\u51b2\u7a81&#xff09;&#xff1a;<\/p>\n<ul>\n<li>\u3010\u4fdd\u59c6\u7ea7\u5b89\u88c5\u6559\u7a0b\u3011&#xff1a;\u4e0d\u4f1a\u5b89\u88c5\u7684\u5c0f\u4f19\u4f34\u76f4\u63a5\u67e5\u770b\u6211\u7684\u4e13\u5c5e\u6559\u7a0b&#xff1a;https:\/\/blog.csdn.net\/zsh_1314520\/article\/details\/156536391&#xff0c;\u4ece\u4e0b\u8f7d\u5230\u73af\u5883\u914d\u7f6e\u4e00\u6b65\u5230\u4f4d&#xff1b;<\/li>\n<li>\u3010\u5b89\u88c5\u5305\u798f\u5229\u3011&#xff1a;\u4e0d\u60f3\u81ea\u5df1\u627e\u8d44\u6e90\u3001\u6015\u4e0b\u8f7d\u5230\u975e\u7eaf\u51c0\u7248\u7684&#xff0c;\u5173\u6ce8\u535a\u4e3b\u540e\u79c1\u4fe1&#xff0c;\u76f4\u63a5\u53d1\u4f60Python\u5168\u5957\u7eaf\u51c0\u5b89\u88c5\u5305&#xff0c;\u89e3\u538b\u5373\u53ef\u7528&#xff0c;\u514d\u914d\u7f6e\u3001\u514d\u6298\u817e&#xff1b;<\/li>\n<li>\u3010\u5173\u952e\u5b89\u88c5\u8981\u6c42\u3011&#xff1a;\u5b89\u88c5\u65f6\u52a1\u5fc5\u52fe\u9009\u300cAdd Python to PATH\u300d\u9009\u9879&#xff0c;\u5c06Python\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf&#xff0c;\u5426\u5219\u7ec8\u7aef\/\u7f16\u8f91\u5668\u65e0\u6cd5\u8bc6\u522bPython\u547d\u4ee4&#xff0c;\u540e\u7eed\u8fd0\u884c\u4ee3\u7801\u4f1a\u62a5\u9519\u3002<\/li>\n<\/ul>\n<h3>2.2 \u5b89\u88c5PyCharm\u7f16\u8f91\u5668<\/h3>\n<p>\u7eaf\u6587\u672c\u7f16\u8f91\u5668&#xff08;\u8bb0\u4e8b\u672c\/Notepad&#043;&#043;&#xff09;\u867d\u80fd\u5199\u4ee3\u7801&#xff0c;\u4f46\u65e0\u4ee3\u7801\u9ad8\u4eae\u3001\u4e00\u952e\u8fd0\u884c\u3001\u8bed\u6cd5\u68c0\u67e5\u529f\u80fd&#xff0c;\u65b0\u624b\u6781\u6613\u56e0\u62fc\u5199\/\u7f29\u8fdb\u9519\u8bef\u51fa\u9519&#xff0c;\u5f3a\u70c8\u63a8\u8350PyCharm\u793e\u533a\u7248&#xff08;\u514d\u8d39\u3001\u529f\u80fd\u8db3\u591f\u3001\u65b0\u624b\u53cb\u597d&#xff09;&#xff1a;<\/p>\n<ul>\n<li>\u3010\u5b89\u88c5\u6559\u7a0b\u3011&#xff1a;\u4e0a\u8ff0\u6559\u7a0b\u94fe\u63a5\u4e2d\u5305\u542bPyCharm\u7684\u5b8c\u6574\u5b89\u88c5\u548c\u57fa\u7840\u4f7f\u7528\u6b65\u9aa4&#xff0c;\u8ddf\u7740\u64cd\u4f5c\u5373\u53ef&#xff1b;<\/li>\n<li>\u3010\u5b89\u88c5\u5305\u798f\u5229\u3011&#xff1a;\u540c\u6837\u53ef\u79c1\u4fe1\u535a\u4e3b\u9886\u53d6PyCharm\u793e\u533a\u7248\u5b89\u88c5\u5305&#xff0c;\u9002\u914dWindows\/Mac\u53cc\u7cfb\u7edf&#xff1b;<\/li>\n<li>\u3010\u6838\u5fc3\u4f18\u52bf\u3011&#xff1a;\u4ee3\u7801\u8bed\u6cd5\u9ad8\u4eae\u3001\u9519\u8bef\u5b9e\u65f6\u63d0\u9192\u3001\u4e00\u952e\u8fd0\u884c\u3001\u4ee3\u7801\u81ea\u52a8\u8865\u5168&#xff0c;\u5927\u5e45\u964d\u4f4e\u65b0\u624b\u5199\u4ee3\u7801\u7684\u96be\u5ea6&#xff0c;\u63d0\u5347\u6548\u7387\u3002<\/li>\n<\/ul>\n<h3>2.3 \u73af\u5883\u9a8c\u8bc1&#xff08;\u786e\u4fddPython&#043;PyCharm\u53ef\u6b63\u5e38\u4f7f\u7528&#xff09;<\/h3>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\u5fc5\u987b\u9a8c\u8bc1\u73af\u5883&#xff0c;\u907f\u514d\u540e\u7eed\u8fd0\u884c\u4ee3\u7801\u51fa\u9519&#xff0c;\u6b65\u9aa4\u5982\u4e0b&#xff1a;<\/p>\n<li>\u6253\u5f00PyCharm&#xff0c;\u70b9\u51fb\u300cFile -&gt; New Project\u300d&#xff0c;\u65b0\u5efa\u7a7a\u767d\u9879\u76ee&#xff08;\u547d\u540d\u4efb\u610f&#xff0c;\u5982Python_Love_Heart&#xff09;&#xff1b;<\/li>\n<li>\u627e\u5230PyCharm\u5e95\u90e8\u7684\u300cTerminal\u300d\u7ec8\u7aef\u7a97\u53e3&#xff0c;\u8f93\u5165\u5bf9\u5e94\u547d\u4ee4\u5e76\u6309\u56de\u8f66&#xff1a;\n<ul>\n<li>Windows\u7cfb\u7edf&#xff1a;python &#8211;version<\/li>\n<li>Mac\/Linux\u7cfb\u7edf&#xff1a;python3 &#8211;version<\/li>\n<\/ul>\n<\/li>\n<li>\u82e5\u7ec8\u7aef\u8f93\u51fa\u300cPython 3.8.x\/3.9.x\/3.10.x\u300d\u7b49\u7248\u672c\u4fe1\u606f&#xff0c;\u8bf4\u660ePython\u89e3\u91ca\u5668\u914d\u7f6e\u6210\u529f&#xff1b;\u82e5\u63d0\u793a\u201c\u4e0d\u662f\u5185\u90e8\u6216\u5916\u90e8\u547d\u4ee4\u201d&#xff0c;\u8bf4\u660e\u672a\u6dfb\u52a0\u73af\u5883\u53d8\u91cf&#xff0c;\u91cd\u65b0\u67e5\u770b\u6559\u7a0b\u914d\u7f6e\u5373\u53ef\u3002<\/li>\n<h3>2.4 \u6838\u5fc3\u6a21\u5757\u5bfc\u5165\u8bf4\u660e&#xff08;\u672c\u6848\u4f8b\u6240\u6709\u4f9d\u8d56&#xff0c;\u65e0\u989d\u5916\u5b89\u88c5&#xff09;<\/h3>\n<p>\u672c\u6848\u4f8b\u4ec5\u4f7f\u7528Python\u5185\u7f6e\u6807\u51c6\u5e93&#xff0c;\u5b89\u88c5Python\u540e\u81ea\u5e26&#xff0c;\u65e0\u9700\u901a\u8fc7pip install\u547d\u4ee4\u5b89\u88c5&#xff0c;\u76f4\u63a5\u5728\u4ee3\u7801\u9996\u884c\u7528import\u5173\u952e\u5b57\u5bfc\u5165\u5373\u53ef&#xff0c;\u4ee5\u4e0b\u662f\u6bcf\u4e2a\u6a21\u5757\u7684\u6838\u5fc3\u4f5c\u7528\u3001\u5bfc\u5165\u65b9\u5f0f\u53ca\u4f7f\u7528\u573a\u666f&#xff0c;\u5fc5\u987b\u7406\u89e3&#xff1a;<\/p>\n<li>random\u5e93&#xff1a;import random&#xff0c;\u7528\u4e8e\u751f\u6210\u968f\u673a\u6570&#xff0c;\u5b9e\u73b0\u7231\u5fc3\u7c92\u5b50\u7684\u968f\u673a\u6269\u6563\u3001\u504f\u79fb&#xff0c;\u8ba9\u7c92\u5b50\u6548\u679c\u66f4\u81ea\u7136&#xff0c;\u907f\u514d\u673a\u68b0\u50f5\u786c&#xff1b;<\/li>\n<li>math\u5e93&#xff1a;from math import sin, cos, pi, log&#xff0c;\u6309\u9700\u5bfc\u5165\u6b63\u5f26\u3001\u4f59\u5f26\u3001\u5706\u5468\u7387\u3001\u5bf9\u6570\u7b49\u51fd\u6570&#xff0c;\u6838\u5fc3\u7528\u4e8e\u7b1b\u5361\u5c14\u5fc3\u5f62\u516c\u5f0f\u8ba1\u7b97\u7231\u5fc3\u5750\u6807\u3001\u751f\u6210\u5468\u671f\u6027\u66f2\u7ebf\u63a7\u5236\u7231\u5fc3\u8df3\u52a8&#xff1b;<\/li>\n<li>tkinter\u5e93&#xff1a;from tkinter import *&#xff0c;\u5bfc\u5165\u6240\u6709\u7ec4\u4ef6&#xff0c;Python\u5185\u7f6e\u7684GUI&#xff08;\u56fe\u5f62\u7528\u6237\u754c\u9762&#xff09;\u5e93&#xff0c;\u6838\u5fc3\u7528\u4e8e\u521b\u5efa\u7a97\u53e3\u3001\u7ed8\u5236\u753b\u5e03\u3001\u5c06\u7231\u5fc3\u5750\u6807\u6e32\u67d3\u4e3a\u53ef\u89c6\u5316\u56fe\u5f62&#xff0c;\u662f\u672c\u6848\u4f8b\u7684\u56fe\u5f62\u8f7d\u4f53\u3002<\/li>\n<h3>2.5 \u65b0\u5efaPython\u6587\u4ef6&#xff08;\u51c6\u5907\u5199\/\u7c98\u8d34\u4ee3\u7801&#xff09;<\/h3>\n<p>\u5728\u5df2\u521b\u5efa\u7684PyCharm\u7a7a\u767d\u9879\u76ee\u4e2d&#xff0c;\u53f3\u952e\u9879\u76ee\u76ee\u5f55 -&gt; \u300cNew -&gt; Python File\u300d&#xff0c;\u65b0\u5efaPython\u6587\u4ef6&#xff08;\u547d\u540d\u4efb\u610f&#xff0c;\u5982dynamic_heart.py&#xff0c;\u540e\u7f00\u5fc5\u987b\u4e3a.py&#xff0c;\u5426\u5219\u4e0d\u5c5e\u4e8ePython\u6587\u4ef6&#xff0c;\u65e0\u6cd5\u8fd0\u884c&#xff09;&#xff0c;\u65b0\u5efa\u5b8c\u6210\u540e\u5373\u53ef\u5728\u6587\u4ef6\u4e2d\u7f16\u5199\u6216\u7c98\u8d34\u4ee3\u7801\u3002<\/p>\n<h2>\u4e09\u3001\u6838\u5fc3\u5b9e\u73b0\u539f\u7406<\/h2>\n<p>\u5728\u67e5\u770b\u4ee3\u7801\u548c\u8be6\u7ec6\u89e3\u6790\u524d&#xff0c;\u5148\u7406\u89e3\u52a8\u6001\u7231\u5fc3\u7684\u6574\u4f53\u5b9e\u73b0\u903b\u8f91&#xff0c;\u505a\u5230\u201c\u77e5\u5176\u7136&#xff0c;\u66f4\u77e5\u5176\u6240\u4ee5\u7136\u201d&#xff0c;\u800c\u975e\u5355\u7eaf\u590d\u5236\u7c98\u8d34&#xff1a;<\/p>\n<li>\u5f62\u72b6\u57fa\u7840&#xff1a;\u901a\u8fc7\u7ecf\u5178\u7b1b\u5361\u5c14\u5fc3\u5f62\u6570\u5b66\u516c\u5f0f&#xff0c;\u904d\u53860-2\u03c0\u7684\u5f27\u5ea6\u503c&#xff0c;\u8ba1\u7b97\u51fa\u7231\u5fc3\u7684\u6240\u6709\u57fa\u7840\u5750\u6807\u70b9&#xff0c;\u786e\u5b9a\u7231\u5fc3\u7684\u6807\u51c6\u3001\u7f8e\u89c2\u8f6e\u5ed3&#xff0c;\u8fd9\u662f\u6240\u6709\u7231\u5fc3\u4ee3\u7801\u7684\u6838\u5fc3&#xff1b;<\/li>\n<li>\u7c92\u5b50\u6548\u679c&#xff1a;\u57fa\u4e8e\u7231\u5fc3\u57fa\u7840\u5750\u6807\u70b9&#xff0c;\u901a\u8fc7random\u5e93\u5b9e\u73b0\u70b9\u7684\u4e2d\u5fc3\u6269\u6563\/\u8fb9\u7f18\u6269\u6563&#xff0c;\u751f\u6210\u5927\u91cf\u7c92\u5b50\u70b9&#xff0c;\u8ba9\u7231\u5fc3\u4ece\u201c\u5355\u4e00\u8f6e\u5ed3\u7ebf\u201d\u53d8\u6210\u201c\u7c92\u5b50\u5316\u586b\u5145\u7684\u5b9e\u4f53\u7231\u5fc3\u201d&#xff1b;<\/li>\n<li>\u52a8\u6001\u8df3\u52a8&#xff1a;\u5229\u7528\u6b63\u5f26\u51fd\u6570\u7684\u5468\u671f\u6027\u5f80\u590d\u7279\u6027&#xff08;\u503c\u5728-1\u52301\u4e4b\u95f4\u5faa\u73af\u53d8\u5316&#xff09;&#xff0c;\u751f\u6210\u968f\u5e27\u6570\u9012\u589e\u7684\u7f29\u653e\u6bd4\u4f8b&#xff0c;\u8ba9\u7231\u5fc3\u7684\u6240\u6709\u7c92\u5b50\u70b9\u6309\u6bd4\u4f8b\u540c\u6b65\u201c\u6536\u7f29-\u6269\u5f20\u201d&#xff0c;\u6a21\u62df\u81ea\u7136\u7684\u8df3\u52a8\u6548\u679c&#xff1b;<\/li>\n<li>\u5149\u6655\u6548\u679c&#xff1a;\u901a\u8fc7\u5bf9\u7231\u5fc3\u57fa\u7840\u5750\u6807\u70b9\u8fdb\u884c\u4e2d\u5fc3\u6536\u7f29&#043;\u968f\u673a\u504f\u79fb&#xff0c;\u751f\u6210\u7231\u5fc3\u5916\u56f4\u7684\u5149\u6655\u7c92\u5b50\u70b9&#xff0c;\u4e14\u5149\u6655\u7684\u534a\u5f84\u3001\u7c92\u5b50\u6570\u91cf\u968f\u7231\u5fc3\u8df3\u52a8\u7684\u7f29\u653e\u6bd4\u4f8b\u540c\u6b65\u53d8\u5316&#xff0c;\u5b9e\u73b0\u548c\u7231\u5fc3\u8282\u594f\u4e00\u81f4\u7684\u52a8\u6001\u5149\u6655&#xff1b;<\/li>\n<li>\u52a8\u6001\u6e32\u67d3&#xff1a;\u901a\u8fc7tkinter\u7684after\u65b9\u6cd5\u5b9e\u73b0\u9010\u5e27\u9012\u5f52\u6e32\u67d3&#xff0c;\u6bcf\u5e27\u6e32\u67d3\u524d\u6e05\u7a7a\u753b\u5e03&#xff0c;\u518d\u91cd\u65b0\u7ed8\u5236\u5f53\u524d\u5e27\u7684\u7231\u5fc3&#xff0c;\u907f\u514d\u5e27\u91cd\u53e0\u5bfc\u81f4\u7684\u753b\u9762\u6df7\u4e71&#xff0c;\u8ba9\u7231\u5fc3\u771f\u6b63\u201c\u52a8\u8d77\u6765\u201d\u3002<\/li>\n<p>\u7b80\u5355\u603b\u7ed3&#xff1a;\u6570\u5b66\u516c\u5f0f\u5b9a\u7231\u5fc3\u5f62\u72b6&#xff0c;tkinter\u505a\u56fe\u5f62\u5c55\u793a\u8f7d\u4f53&#xff0c;\u968f\u673a\u6570\u6253\u9020\u7c92\u5b50\u6548\u679c&#xff0c;\u6b63\u5f26\u66f2\u7ebf\u63a7\u5236\u8df3\u52a8\u8282\u594f&#xff0c;\u9010\u5e27\u6e32\u67d3\u5b9e\u73b0\u52a8\u6001\u89c6\u89c9\u3002<\/p>\n<h2>\u56db\u3001\u4ee3\u7801\u8be6\u89e3<\/h2>\n<p>\u672c\u6848\u4f8b\u7684\u4ee3\u7801\u6309\u529f\u80fd\u6a21\u5757\u5212\u5206\u4e3a5\u4e2a\u6838\u5fc3\u90e8\u5206&#xff0c;\u5404\u6a21\u5757\u5404\u53f8\u5176\u804c\u3001\u76f8\u4e92\u914d\u5408&#xff0c;\u6700\u7ec8\u5b9e\u73b0\u52a8\u6001\u8df3\u52a8\u7231\u5fc3\u6548\u679c&#xff0c;\u4ee5\u4e0b\u662f\u5bf9\u6bcf\u4e2a\u6a21\u5757\u7684\u8d85\u8be6\u7ec6\u6587\u672c\u89e3\u6790&#xff0c;\u7ed3\u5408\u4ee3\u7801\u4e2d\u7684\u6ce8\u91ca&#xff0c;\u8ba9\u96f6\u57fa\u7840\u65b0\u624b\u4e5f\u80fd\u5f7b\u5e95\u7406\u89e3\u6bcf\u4e00\u90e8\u5206\u7684\u4f5c\u7528\u548c\u903b\u8f91&#xff01;<\/p>\n<h3>4.1 \u5168\u5c40\u5e38\u91cf\u914d\u7f6e\u533a<\/h3>\n<p>\u8fd9\u662f\u4ee3\u7801\u7684\u6700\u5f00\u5934\u90e8\u5206&#xff0c;\u5b9a\u4e49\u4e86\u6240\u6709\u53ef\u76f4\u63a5\u4fee\u6539\u7684\u5e38\u91cf&#xff0c;\u65e0\u9700\u7406\u89e3\u590d\u6742\u903b\u8f91&#xff0c;\u76f4\u63a5\u4fee\u6539\u6570\u503c\u5c31\u80fd\u8c03\u6574\u7231\u5fc3\u6837\u5f0f\u3001\u753b\u5e03\u5927\u5c0f&#xff0c;\u662f\u65b0\u624b\u6700\u5bb9\u6613\u4e0a\u624b\u5b9a\u5236\u7684\u90e8\u5206&#xff0c;\u6bcf\u4e2a\u5e38\u91cf\u7684\u5177\u4f53\u4f5c\u7528\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>CANVAS_WIDTH\/CANVAS_HEIGHT&#xff1a;\u5b9a\u4e49\u753b\u5e03&#xff08;\u5373\u5f39\u51fa\u7684\u56fe\u5f62\u7a97\u53e3&#xff09;\u7684\u5bbd\u548c\u9ad8&#xff0c;\u5355\u4f4d\u4e3a\u50cf\u7d20&#xff0c;\u6570\u503c\u8d8a\u5927\u7a97\u53e3\u8d8a\u5927&#xff1b;<\/li>\n<li>CANVAS_CENTER_X\/CANVAS_CENTER_Y&#xff1a;\u901a\u8fc7\u753b\u5e03\u5bbd\u9ad8\u8ba1\u7b97\u51fa\u753b\u5e03\u7684\u4e2d\u5fc3\u5750\u6807&#xff0c;\u76ee\u7684\u662f\u8ba9\u7231\u5fc3\u7ed8\u5236\u5728\u753b\u5e03\u6b63\u4e2d\u5fc3&#xff08;tkinter\u753b\u5e03\u7684\u539f\u70b9\u9ed8\u8ba4\u5728\u5de6\u4e0a\u89d2&#xff0c;\u4e0d\u504f\u79fb\u4f1a\u5bfc\u81f4\u7231\u5fc3\u663e\u793a\u5728\u89d2\u843d&#xff09;&#xff1b;<\/li>\n<li>IMAGE_ENLARGE&#xff1a;\u7231\u5fc3\u7684\u57fa\u7840\u7f29\u653e\u6bd4\u4f8b&#xff0c;\u7b1b\u5361\u5c14\u5fc3\u5f62\u516c\u5f0f\u751f\u6210\u7684\u539f\u59cb\u5750\u6807\u70b9\u5c3a\u5bf8\u6781\u5c0f&#xff0c;\u5fc5\u987b\u7f29\u653e\u540e\u624d\u80fd\u5728\u753b\u5e03\u4e0a\u6e05\u6670\u663e\u793a&#xff0c;\u6570\u503c\u8d8a\u5927\u7231\u5fc3\u6574\u4f53\u8d8a\u5927&#xff1b;<\/li>\n<li>HEART_COLOR&#xff1a;\u7231\u5fc3\u7c92\u5b50\u7684\u989c\u8272&#xff0c;\u4f7f\u752816\u8fdb\u5236\u8272\u503c\u8868\u793a&#xff0c;\u53ef\u76f4\u63a5\u66ff\u6362\u4e3a\u5176\u4ed6\u989c\u8272&#xff08;\u5982\u6b63\u7ea2\u8272#FF0000\u3001\u6df1\u7d2b\u8272#9370DB&#xff09;\u3002<\/li>\n<\/ul>\n<h3>4.2 \u6838\u5fc3\u5de5\u5177\u51fd\u6570<\/h3>\n<p>\u8fd9\u90e8\u5206\u5305\u542b4\u4e2a\u72ec\u7acb\u7684\u5de5\u5177\u51fd\u6570&#xff0c;\u662f\u5b9e\u73b0\u7231\u5fc3\u5f62\u72b6\u751f\u6210\u3001\u7c92\u5b50\u6269\u6563\u3001\u8df3\u52a8\u8282\u594f\u63a7\u5236\u7684\u57fa\u7840&#xff0c;\u4e3a\u540e\u7eed\u7684\u7231\u5fc3\u6838\u5fc3\u7c7b\u63d0\u4f9b\u5e95\u5c42\u529f\u80fd\u652f\u6301&#xff0c;\u6bcf\u4e2a\u51fd\u6570\u7684\u89e3\u6790\u5982\u4e0b&#xff1a;<\/p>\n<h4>4.2.1 heart_function(t, shrink_ratio&#061;IMAGE_ENLARGE)<\/h4>\n<ul>\n<li>\u6838\u5fc3\u4f5c\u7528&#xff1a;\u6839\u636e\u7b1b\u5361\u5c14\u5fc3\u5f62\u516c\u5f0f&#xff0c;\u901a\u8fc7\u4f20\u5165\u7684\u5f27\u5ea6\u503ct&#xff0c;\u8ba1\u7b97\u51fa\u7231\u5fc3\u7684\u5355\u4e2a\u5750\u6807\u70b9&#xff0c;\u904d\u53860-2\u03c0\u7684\u5f27\u5ea6\u503c\u5373\u53ef\u751f\u6210\u5b8c\u6574\u7231\u5fc3\u8f6e\u5ed3&#xff0c;\u662f\u7231\u5fc3\u5f62\u72b6\u7684\u6838\u5fc3\u51fd\u6570&#xff1b;<\/li>\n<li>\u53c2\u6570\u8bf4\u660e&#xff1a;t\u4e3a\u5f27\u5ea6\u503c&#xff08;\u8303\u56f40-2\u03c0&#xff09;&#xff1b;shrink_ratio\u4e3a\u7f29\u653e\u6bd4\u4f8b&#xff0c;\u9ed8\u8ba4\u8c03\u7528\u5168\u5c40\u5e38\u91cfIMAGE_ENLARGE&#xff0c;\u4e5f\u53ef\u624b\u52a8\u4f20\u5165\u6570\u503c&#xff1b;<\/li>\n<li>\u5173\u952e\u903b\u8f91&#xff1a;\u5148\u901a\u8fc7\u7b1b\u5361\u5c14\u5fc3\u5f62\u516c\u5f0f\u8ba1\u7b97\u539f\u59cb\u5750\u6807&#xff0c;\u518d\u7f29\u653e\u5750\u6807\u9002\u914d\u753b\u5e03\u5c3a\u5bf8&#xff0c;\u6700\u540e\u504f\u79fb\u5750\u6807\u8ba9\u7231\u5fc3\u5c45\u4e2d&#xff0c;\u6700\u7ec8\u8fd4\u56de\u6574\u6570\u50cf\u7d20\u5750\u6807&#xff08;tkinter\u753b\u5e03\u7684\u5750\u6807\u5fc5\u987b\u4e3a\u6574\u6570&#xff0c;\u4e0d\u80fd\u662f\u6d6e\u70b9\u6570&#xff09;\u3002<\/li>\n<\/ul>\n<h4>4.2.2 scatter_inside(x, y, beta&#061;0.15)<\/h4>\n<ul>\n<li>\u6838\u5fc3\u4f5c\u7528&#xff1a;\u8ba9\u7231\u5fc3\u7684\u57fa\u7840\u5750\u6807\u70b9\u5411\u753b\u5e03\u4e2d\u5fc3\u968f\u673a\u6269\u6563&#xff0c;\u751f\u6210\u7c92\u5b50\u6548\u679c&#xff0c;\u662f\u6253\u9020\u7c92\u5b50\u5316\u7231\u5fc3\u7684\u5173\u952e\u51fd\u6570&#xff1b;<\/li>\n<li>\u53c2\u6570\u8bf4\u660e&#xff1a;x\/y\u4e3a\u7231\u5fc3\u57fa\u7840\u5750\u6807\u70b9&#xff1b;beta\u4e3a\u6269\u6563\u7cfb\u6570&#xff0c;\u6570\u503c\u8d8a\u5c0f\u6269\u6563\u8303\u56f4\u8d8a\u5c0f&#xff0c;\u7c92\u5b50\u8d8a\u5bc6\u96c6&#xff0c;\u53cd\u4e4b\u7c92\u5b50\u8d8a\u7a00\u758f&#xff1b;<\/li>\n<li>\u5173\u952e\u903b\u8f91&#xff1a;\u901a\u8fc7\u5bf9\u6570\u968f\u673a\u6570\u751f\u6210\u7b26\u5408\u81ea\u7136\u5206\u5e03\u7684\u6269\u6563\u6bd4\u4f8b&#xff0c;\u8ba1\u7b97\u51fa\u70b9\u5411\u753b\u5e03\u4e2d\u5fc3\u7684\u504f\u79fb\u91cf&#xff0c;\u539f\u59cb\u5750\u6807\u51cf\u53bb\u504f\u79fb\u91cf&#xff0c;\u5f97\u5230\u6269\u6563\u540e\u7684\u65b0\u5750\u6807&#xff0c;\u5b9e\u73b0\u70b9\u201c\u5411\u4e2d\u5fc3\u805a\u96c6\u201d\u7684\u7c92\u5b50\u6548\u679c\u3002<\/li>\n<\/ul>\n<h4>4.2.3 shrink(x, y, ratio)<\/h4>\n<ul>\n<li>\u6838\u5fc3\u4f5c\u7528&#xff1a;\u8ba9\u5750\u6807\u70b9\u5411\u753b\u5e03\u4e2d\u5fc3\u6536\u7f29&#xff0c;\u4e13\u95e8\u7528\u4e8e\u751f\u6210\u7231\u5fc3\u5916\u56f4\u7684\u5149\u6655\u6548\u679c&#xff0c;\u65e0\u6b64\u51fd\u6570\u5219\u7231\u5fc3\u65e0\u5149\u6655&#xff0c;\u89c6\u89c9\u6548\u679c\u66f4\u5355\u8c03&#xff1b;<\/li>\n<li>\u53c2\u6570\u8bf4\u660e&#xff1a;x\/y\u4e3a\u7231\u5fc3\u57fa\u7840\u5750\u6807\u70b9&#xff1b;ratio\u4e3a\u6536\u7f29\u6bd4\u4f8b&#xff0c;\u6570\u503c\u8d8a\u5927\u6536\u7f29\u6548\u679c\u8d8a\u660e\u663e&#xff1b;<\/li>\n<li>\u5173\u952e\u903b\u8f91&#xff1a;\u8ba1\u7b97\u70b9\u5230\u753b\u5e03\u4e2d\u5fc3\u7684\u201c\u6536\u7f29\u529b\u201d&#xff0c;\u8ddd\u79bb\u4e2d\u5fc3\u8d8a\u8fdc\u7684\u70b9&#xff0c;\u6536\u7f29\u529b\u8d8a\u5927&#xff0c;\u4ee5\u6b64\u751f\u6210\u81ea\u7136\u3001\u8d34\u5408\u7231\u5fc3\u8f6e\u5ed3\u7684\u5149\u6655\u57fa\u7840\u8f6e\u5ed3\u3002<\/li>\n<\/ul>\n<h4>4.2.4 curve(p)<\/h4>\n<ul>\n<li>\u6838\u5fc3\u4f5c\u7528&#xff1a;\u751f\u6210\u5468\u671f\u6027\u7684\u6b63\u5f26\u66f2\u7ebf&#xff0c;\u8fd4\u56de\u968f\u53c2\u6570p\u53d8\u5316\u7684\u7f29\u653e\u6bd4\u4f8b\u503c&#xff0c;\u662f\u63a7\u5236\u7231\u5fc3\u8df3\u52a8\u8282\u594f\u7684\u6838\u5fc3\u51fd\u6570&#xff1b;<\/li>\n<li>\u53c2\u6570\u8bf4\u660e&#xff1a;p\u4e3a\u968f\u5e27\u6570\u9012\u589e\u7684\u53c2\u6570&#xff0c;\u7528\u4e8e\u63a7\u5236\u6b63\u5f26\u66f2\u7ebf\u7684\u53d8\u5316&#xff1b;<\/li>\n<li>\u5173\u952e\u903b\u8f91&#xff1a;\u5229\u7528\u6b63\u5f26\u51fd\u6570sin\u7684\u5468\u671f\u6027\u5f80\u590d\u7279\u6027&#xff0c;\u751f\u6210\u5728\u4e00\u5b9a\u8303\u56f4\u5185\u5faa\u73af\u53d8\u5316\u7684\u7f29\u653e\u6bd4\u4f8b\u503c&#xff0c;\u4e3a\u540e\u7eed\u7231\u5fc3\u7c92\u5b50\u7684\u7f29\u653e\u63d0\u4f9b\u4f9d\u636e&#xff0c;\u5b9e\u73b0\u201c\u6536\u7f29-\u6269\u5f20\u201d\u7684\u8df3\u52a8\u6548\u679c\u3002<\/li>\n<\/ul>\n<h3>4.3 Heart\u6838\u5fc3\u7c7b<\/h3>\n<p>\u8fd9\u90e8\u5206\u662f\u6574\u4e2a\u6848\u4f8b\u7684\u6838\u5fc3\u903b\u8f91\u5c01\u88c5&#xff0c;\u91c7\u7528Python\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u7684\u601d\u60f3&#xff0c;\u5c06\u7231\u5fc3\u7684\u70b9\u96c6\u5408\u6784\u5efa\u3001\u5e27\u6570\u636e\u9884\u8ba1\u7b97\u3001\u7c92\u5b50\u6e32\u67d3\u7b49\u6240\u6709\u6838\u5fc3\u903b\u8f91\u5c01\u88c5\u4e3a\u4e00\u4e2a\u7c7b&#xff0c;\u8ba9\u4ee3\u7801\u7ed3\u6784\u66f4\u6e05\u6670\u3001\u4fbf\u4e8e\u7ef4\u62a4\u548c\u540e\u7eed\u62d3\u5c55&#xff0c;\u7c7b\u4e2d\u7684\u6bcf\u4e2a\u65b9\u6cd5\u5206\u5de5\u660e\u786e&#xff0c;\u89e3\u6790\u5982\u4e0b&#xff1a;<\/p>\n<h4>4.3.1 __init__ \u521d\u59cb\u5316\u65b9\u6cd5<\/h4>\n<ul>\n<li>\u6838\u5fc3\u4f5c\u7528&#xff1a;\u521b\u5efa\u7231\u5fc3\u6240\u9700\u7684\u5404\u7c7b\u70b9\u96c6\u5408&#xff0c;\u6307\u5b9a\u7231\u5fc3\u4e00\u4e2a\u8df3\u52a8\u5468\u671f\u7684\u603b\u5e27\u6570&#xff0c;\u8c03\u7528build\u65b9\u6cd5\u6784\u5efa\u57fa\u7840\u70b9\u96c6\u5408&#xff0c;\u5e76\u9884\u8ba1\u7b97\u6240\u6709\u5e27\u7684\u7c92\u5b50\u70b9\u6570\u636e&#xff1b;<\/li>\n<li>\u5173\u952e\u4f18\u5316\u70b9&#xff1a;\u63d0\u524d\u9884\u8ba1\u7b97\u6240\u6709\u5e27\u7684\u70b9\u6570\u636e&#xff0c;\u800c\u975e\u7a0b\u5e8f\u8fd0\u884c\u65f6\u5b9e\u65f6\u8ba1\u7b97&#xff0c;\u80fd\u907f\u514d\u5b9e\u65f6\u8ba1\u7b97\u5bfc\u81f4\u7684\u753b\u9762\u5361\u987f&#xff0c;\u8ba9\u7231\u5fc3\u6e32\u67d3\u66f4\u6d41\u7545&#xff0c;\u8fd9\u662f\u63d0\u5347\u7a0b\u5e8f\u6027\u80fd\u7684\u91cd\u8981\u6280\u5de7&#xff1b;<\/li>\n<li>\u6838\u5fc3\u5c5e\u6027\u8bf4\u660e&#xff1a;\n<ul>\n<li>_points&#xff1a;\u539f\u59cb\u7231\u5fc3\u8f6e\u5ed3\u70b9\u96c6\u5408&#xff08;\u4f7f\u7528set\u96c6\u5408\u4fdd\u8bc1\u65e0\u91cd\u590d\u70b9&#xff09;&#xff0c;\u7528\u4e8e\u786e\u5b9a\u7231\u5fc3\u7684\u57fa\u7840\u5f62\u72b6&#xff1b;<\/li>\n<li>_edge_diffusion_points&#xff1a;\u7231\u5fc3\u8fb9\u7f18\u6269\u6563\u70b9\u96c6\u5408&#xff0c;\u7528\u4e8e\u67d4\u5316\u7231\u5fc3\u8fb9\u7f18&#xff0c;\u907f\u514d\u8f6e\u5ed3\u751f\u786c&#xff1b;<\/li>\n<li>_center_diffusion_points&#xff1a;\u7231\u5fc3\u4e2d\u5fc3\u6269\u6563\u70b9\u96c6\u5408&#xff0c;\u7528\u4e8e\u586b\u5145\u7231\u5fc3\u5185\u90e8&#xff0c;\u8ba9\u7231\u5fc3\u6210\u4e3a\u9971\u6ee1\u7684\u5b9e\u4f53&#xff1b;<\/li>\n<li>all_points&#xff1a;\u5b57\u5178\u7c7b\u578b&#xff0c;\u952e\u4e3a\u5e27\u6570&#xff0c;\u503c\u4e3a\u5bf9\u5e94\u5e27\u7684\u7c92\u5b50\u70b9\u5217\u8868&#xff08;\u5305\u542bx\u5750\u6807\u3001y\u5750\u6807\u3001\u7c92\u5b50\u5927\u5c0f&#xff09;&#xff0c;\u5b58\u50a8\u6240\u6709\u5e27\u7684\u6e32\u67d3\u6570\u636e\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>4.3.2 build(number) \u70b9\u96c6\u5408\u6784\u5efa\u65b9\u6cd5<\/h4>\n<ul>\n<li>\u6838\u5fc3\u4f5c\u7528&#xff1a;\u6784\u5efa\u7231\u5fc3\u7684\u4e09\u7c7b\u57fa\u7840\u70b9\u96c6\u5408&#xff08;\u539f\u59cb\u70b9\u3001\u8fb9\u7f18\u6269\u6563\u70b9\u3001\u4e2d\u5fc3\u6269\u6563\u70b9&#xff09;&#xff0c;\u662f\u751f\u6210\u7c92\u5b50\u5316\u7231\u5fc3\u7684\u57fa\u7840&#xff0c;\u65e0\u6b64\u65b9\u6cd5\u5219\u7231\u5fc3\u4ec5\u4e3a\u5355\u4e00\u8f6e\u5ed3&#xff1b;<\/li>\n<li>\u53c2\u6570\u8bf4\u660e&#xff1a;number\u4e3a\u539f\u59cb\u7231\u5fc3\u8f6e\u5ed3\u70b9\u7684\u6570\u91cf&#xff0c;\u6570\u503c\u8d8a\u5927\u7231\u5fc3\u8f6e\u5ed3\u8d8a\u6e05\u6670\u3001\u7c92\u5b50\u8d8a\u5bc6\u96c6&#xff1b;<\/li>\n<li>\u5206\u6b65\u9aa4\u903b\u8f91&#xff1a;\n<li>\u751f\u6210\u539f\u59cb\u70b9&#xff1a;\u968f\u673a\u751f\u62100-2\u03c0\u7684\u5f27\u5ea6\u503c&#xff0c;\u8c03\u7528heart_function\u8ba1\u7b97\u5bf9\u5e94\u5750\u6807&#xff0c;\u6dfb\u52a0\u5230\u539f\u59cb\u70b9\u96c6\u5408&#xff1b;<\/li>\n<li>\u751f\u6210\u8fb9\u7f18\u6269\u6563\u70b9&#xff1a;\u4e3a\u6bcf\u4e2a\u539f\u59cb\u70b9\u751f\u62103\u4e2a\u5c0f\u7cfb\u6570\u6269\u6563\u70b9&#xff0c;\u67d4\u5316\u7231\u5fc3\u8fb9\u7f18&#xff1b;<\/li>\n<li>\u751f\u6210\u4e2d\u5fc3\u6269\u6563\u70b9&#xff1a;\u4ece\u539f\u59cb\u70b9\u4e2d\u968f\u673a\u9009\u53d6&#xff0c;\u751f\u62104000\u4e2a\u5927\u7cfb\u6570\u6269\u6563\u70b9&#xff0c;\u586b\u5145\u7231\u5fc3\u5185\u90e8\u3002<\/li>\n<\/li>\n<\/ul>\n<h4>4.3.3 calc_position(x, y, ratio) \u9759\u6001\u65b9\u6cd5<\/h4>\n<ul>\n<li>\u6838\u5fc3\u4f5c\u7528&#xff1a;\u6839\u636e\u5f53\u524d\u5e27\u7684\u7f29\u653e\u6bd4\u4f8b&#xff0c;\u8ba1\u7b97\u7c92\u5b50\u70b9\u7684\u65b0\u5750\u6807&#xff0c;\u8ba9\u6240\u6709\u7c92\u5b50\u70b9\u6309\u6bd4\u4f8b\u540c\u6b65\u504f\u79fb&#xff0c;\u5b9e\u73b0\u7231\u5fc3\u7684\u52a8\u6001\u8df3\u52a8&#xff1b;<\/li>\n<li>\u53c2\u6570\u8bf4\u660e&#xff1a;x\/y\u4e3a\u7c92\u5b50\u70b9\u539f\u59cb\u5750\u6807&#xff1b;ratio\u4e3a\u5f53\u524d\u5e27\u7684\u7f29\u653e\u6bd4\u4f8b&#xff08;\u7531curve\u51fd\u6570\u751f\u6210&#xff09;&#xff1b;<\/li>\n<li>\u5173\u952e\u903b\u8f91&#xff1a;\u8ba1\u7b97\u70b9\u5230\u753b\u5e03\u4e2d\u5fc3\u7684\u201c\u8df3\u52a8\u529b\u201d&#xff0c;\u8ddd\u79bb\u4e2d\u5fc3\u8d8a\u8fdc\u7684\u70b9&#xff0c;\u8df3\u52a8\u5e45\u5ea6\u8d8a\u5927&#xff0c;\u8ba9\u7231\u5fc3\u8df3\u52a8\u66f4\u6709\u7acb\u4f53\u611f&#xff1b;\u5728\u504f\u79fb\u91cf\u4e2d\u52a0\u5165\u8f7b\u5fae\u968f\u673a\u503c&#xff0c;\u8ba9\u7c92\u5b50\u8df3\u52a8\u66f4\u81ea\u7136&#xff0c;\u907f\u514d\u673a\u68b0\u3001\u91cd\u590d\u7684\u8df3\u52a8\u6548\u679c\u3002<\/li>\n<\/ul>\n<h4>4.3.4 calc(generate_frame) \u5e27\u6570\u636e\u9884\u8ba1\u7b97\u65b9\u6cd5<\/h4>\n<ul>\n<li>\u6838\u5fc3\u4f5c\u7528&#xff1a;\u9884\u8ba1\u7b97\u6307\u5b9a\u5e27\u6570\u7684\u6240\u6709\u7c92\u5b50\u70b9\u6570\u636e&#xff0c;\u5305\u62ec\u7231\u5fc3\u7c92\u5b50\u70b9\u548c\u5149\u6655\u7c92\u5b50\u70b9&#xff0c;\u662f\u5b9e\u73b0\u52a8\u6001\u6548\u679c\u7684\u5173\u952e&#xff1b;<\/li>\n<li>\u53c2\u6570\u8bf4\u660e&#xff1a;generate_frame\u4e3a\u9700\u8981\u8ba1\u7b97\u7684\u5e27\u6570&#xff1b;<\/li>\n<li>\u5173\u952e\u903b\u8f91&#xff1a;\u5148\u6839\u636e\u5f53\u524d\u5e27\u6570\u8ba1\u7b97\u51fa\u7f29\u653e\u6bd4\u4f8b&#xff0c;\u518d\u540c\u6b65\u8ba1\u7b97\u5149\u6655\u7684\u534a\u5f84\u548c\u7c92\u5b50\u6570\u91cf&#xff0c;\u968f\u540e\u4f9d\u6b21\u751f\u6210\u5149\u6655\u7c92\u5b50\u70b9\u3001\u539f\u59cb\u7231\u5fc3\u7c92\u5b50\u70b9\u3001\u8fb9\u7f18\u6269\u6563\u7c92\u5b50\u70b9\u3001\u4e2d\u5fc3\u6269\u6563\u7c92\u5b50\u70b9&#xff0c;\u6700\u540e\u5c06\u6240\u6709\u7c92\u5b50\u70b9\u6570\u636e\u4fdd\u5b58\u5230all_points\u5b57\u5178\u4e2d&#xff0c;\u4f9b\u6e32\u67d3\u65f6\u8c03\u7528\u3002<\/li>\n<\/ul>\n<h4>4.3.5 render(render_canvas, render_frame) \u6e32\u67d3\u65b9\u6cd5<\/h4>\n<ul>\n<li>\u6838\u5fc3\u4f5c\u7528&#xff1a;\u5c06\u6307\u5b9a\u5e27\u6570\u7684\u7c92\u5b50\u70b9\u6570\u636e\u7ed8\u5236\u5230tkinter\u753b\u5e03\u4e0a&#xff0c;\u5b9e\u73b0\u7231\u5fc3\u7684\u53ef\u89c6\u5316&#xff1b;<\/li>\n<li>\u53c2\u6570\u8bf4\u660e&#xff1a;render_canvas\u4e3atkinter\u7684\u753b\u5e03\u5bf9\u8c61&#xff1b;render_frame\u4e3a\u5f53\u524d\u8981\u6e32\u67d3\u7684\u5e27\u6570&#xff1b;<\/li>\n<li>\u5173\u952e\u7ec6\u8282&#xff1a;\n<li>\u5faa\u73af\u53d6\u5e27&#xff1a;\u901a\u8fc7render_frame % self.generate_frame\u8ba9\u5e27\u6570\u8d85\u8fc7\u8df3\u52a8\u5468\u671f\u540e\u4ece0\u91cd\u65b0\u5f00\u59cb&#xff0c;\u5b9e\u73b0\u7231\u5fc3\u65e0\u9650\u5faa\u73af\u8df3\u52a8&#xff1b;<\/li>\n<li>\u77e9\u5f62\u7ed8\u5236\u7c92\u5b50&#xff1a;\u4f7f\u7528\u5b9e\u5fc3\u77e9\u5f62\u7ed8\u5236\u7c92\u5b50&#xff08;\u800c\u975e\u5706\u5f62&#xff09;&#xff0c;\u539f\u56e0\u662ftkinter\u4e2d\u77e9\u5f62\u7684\u6e32\u67d3\u901f\u5ea6\u8fdc\u5feb\u4e8e\u5706\u5f62&#xff0c;\u80fd\u4fdd\u8bc1\u4f4e\u914d\u8bbe\u5907\u4e5f\u80fd\u6d41\u7545\u8fd0\u884c&#xff0c;\u4e14\u7c92\u5b50\u5c3a\u5bf8\u8db3\u591f\u5c0f\u65f6&#xff0c;\u77e9\u5f62\u89c6\u89c9\u6548\u679c\u4e0e\u5706\u5f62\u65e0\u5dee\u5f02&#xff1b;<\/li>\n<li>\u5b9e\u5fc3\u7ed8\u5236&#xff1a;\u901a\u8fc7width&#061;0\u5b9e\u73b0\u77e9\u5f62\u7684\u5b9e\u5fc3\u7ed8\u5236&#xff0c;\u8ba9\u7c92\u5b50\u66f4\u660e\u663e\u3002<\/li>\n<\/li>\n<\/ul>\n<h3>4.4 \u52a8\u6001\u7ed8\u5236\u5faa\u73afdraw\u51fd\u6570<\/h3>\n<ul>\n<li>\u6838\u5fc3\u4f5c\u7528&#xff1a;\u5b9e\u73b0\u7231\u5fc3\u7684\u9010\u5e27\u9012\u5f52\u6e32\u67d3&#xff0c;\u662f\u8fde\u63a5Heart\u6838\u5fc3\u7c7b\u548ctkinter\u7a97\u53e3\u7684\u5173\u952e&#xff0c;\u8ba9\u7231\u5fc3\u771f\u6b63\u201c\u52a8\u8d77\u6765\u201d&#xff1b;<\/li>\n<li>\u53c2\u6570\u8bf4\u660e&#xff1a;main\u4e3atkinter\u4e3b\u7a97\u53e3\u5bf9\u8c61&#xff1b;render_canvas\u4e3a\u753b\u5e03\u5bf9\u8c61&#xff1b;render_heart\u4e3aHeart\u7231\u5fc3\u5bf9\u8c61&#xff1b;render_frame\u4e3a\u5f53\u524d\u6e32\u67d3\u5e27\u6570&#xff0c;\u521d\u59cb\u503c\u4e3a0&#xff1b;<\/li>\n<li>\u5173\u952e\u903b\u8f91&#xff1a;\u6bcf\u5e27\u6e32\u67d3\u524d\u5148\u6e05\u7a7a\u753b\u5e03&#xff08;\u907f\u514d\u4e0a\u4e00\u5e27\u4e0e\u5f53\u524d\u5e27\u91cd\u53e0\u5bfc\u81f4\u753b\u9762\u6df7\u4e71&#xff09;&#xff0c;\u518d\u8c03\u7528\u7231\u5fc3\u5bf9\u8c61\u7684render\u65b9\u6cd5\u6e32\u67d3\u5f53\u524d\u5e27&#xff0c;\u6700\u540e\u901a\u8fc7tkinter\u7684after\u65b9\u6cd5160\u6beb\u79d2\u540e\u9012\u5f52\u8c03\u7528\u81ea\u8eab&#xff0c;\u5b9e\u73b0\u6301\u7eed\u7684\u52a8\u6001\u5237\u65b0\u3002<\/li>\n<\/ul>\n<h3>4.5 \u4e3b\u7a0b\u5e8f\u5165\u53e3if __name__ &#061;&#061; &#039;__main__&#039;<\/h3>\n<ul>\n<li>\u6838\u5fc3\u4f5c\u7528&#xff1a;\u6267\u884c\u6574\u4e2a\u6848\u4f8b\u7684\u6240\u6709\u903b\u8f91&#xff0c;\u662f\u4ee3\u7801\u7684\u552f\u4e00\u5165\u53e3&#xff0c;\u53ea\u6709\u76f4\u63a5\u8fd0\u884c\u8be5Python\u6587\u4ef6\u65f6&#xff0c;\u8fd9\u90e8\u5206\u4ee3\u7801\u624d\u4f1a\u6267\u884c&#xff1b;<\/li>\n<li>\u5206\u6b65\u9aa4\u903b\u8f91&#xff1a;\n<li>\u521b\u5efatkinter\u4e3b\u7a97\u53e3\u5bf9\u8c61&#xff0c;\u4f5c\u4e3a\u6240\u6709\u56fe\u5f62\u7684\u9876\u5c42\u8f7d\u4f53&#xff1b;<\/li>\n<li>\u8bbe\u7f6e\u7a97\u53e3\u6807\u9898&#xff0c;\u53ef\u81ea\u5b9a\u4e49\u4fee\u6539&#xff1b;<\/li>\n<li>\u521b\u5efa\u753b\u5e03\u5bf9\u8c61&#xff0c;\u6307\u5b9a\u9ed1\u8272\u80cc\u666f\u548c\u9884\u8bbe\u7684\u5bbd\u9ad8&#xff1b;<\/li>\n<li>\u5c06\u753b\u5e03\u5e03\u5c40\u5230\u4e3b\u7a97\u53e3\u4e2d&#xff08;\u65e0\u6b64\u6b65\u9aa4\u753b\u5e03\u65e0\u6cd5\u663e\u793a&#xff09;&#xff1b;<\/li>\n<li>\u521d\u59cb\u5316Heart\u7231\u5fc3\u5bf9\u8c61&#xff0c;\u52a0\u8f7d\u6240\u6709\u5e27\u7684\u7c92\u5b50\u70b9\u6570\u636e&#xff1b;<\/li>\n<li>\u542f\u52a8\u52a8\u6001\u7ed8\u5236\u5faa\u73af&#xff0c;\u5f00\u59cb\u9010\u5e27\u6e32\u67d3\u7231\u5fc3&#xff1b;<\/li>\n<li>\u8fdb\u5165tkinter\u4e3b\u4e8b\u4ef6\u5faa\u73af&#xff0c;\u8ba9\u7a97\u53e3\u4fdd\u6301\u663e\u793a&#xff08;\u5173\u95ed\u7a97\u53e3\u5219\u5faa\u73af\u7ed3\u675f&#xff0c;\u7a0b\u5e8f\u505c\u6b62&#xff09;\u3002<\/li>\n<\/li>\n<\/ul>\n<h2>\u4e94\u3001\u4ee3\u7801\u5c55\u793a<\/h2>\n<p>\u4ee5\u4e0b\u662f\u672c\u6848\u4f8b\u7684\u5b8c\u6574\u4ee3\u7801&#xff0c;\u4ee3\u7801\u4e2d\u5305\u542b\u7b80\u6d01\u6e05\u6670\u7684\u884c\u5185\u6ce8\u91ca&#xff08;\u8f85\u52a9\u7406\u89e3\u5173\u952e\u4ee3\u7801&#xff09;&#xff0c;\u6838\u5fc3\u903b\u8f91\u5df2\u5728\u300c\u4ee3\u7801\u8be6\u89e3\u300d\u90e8\u5206\u505a\u4e86\u8d85\u8be6\u7ec6\u6587\u672c\u89e3\u6790&#xff0c;\u76f4\u63a5\u5c06\u4ee3\u7801\u5168\u9009\u590d\u5236\u5230\u65b0\u5efa\u7684Python\u6587\u4ef6\u4e2d&#xff0c;\u70b9\u51fbPyCharm\u53f3\u4e0a\u89d2\u7684\u7eff\u8272\u4e09\u89d2\u8fd0\u884c\u6309\u94ae&#xff0c;\u5373\u53ef\u770b\u5230\u52a8\u6001\u8df3\u52a8\u7231\u5fc3\u6548\u679c&#xff0c;\u65e0\u9700\u4fee\u6539\u4efb\u4f55\u4ee3\u7801&#xff01;<\/p>\n<p><span class=\"token comment\"># \u5bfc\u5165\u672c\u6848\u4f8b\u6240\u9700\u6240\u6709\u5185\u7f6e\u5e93&#xff0c;\u65e0\u9700\u989d\u5916\u5b89\u88c5\u7b2c\u4e09\u65b9\u5305<\/span><br \/>\n<span class=\"token keyword\">import<\/span> random<br \/>\n<span class=\"token comment\"># \u6309\u9700\u5bfc\u5165math\u5e93\u7684\u6838\u5fc3\u51fd\u6570&#xff0c;\u7528\u4e8e\u6570\u5b66\u8ba1\u7b97<\/span><br \/>\n<span class=\"token keyword\">from<\/span> math <span class=\"token keyword\">import<\/span> sin<span class=\"token punctuation\">,<\/span> cos<span class=\"token punctuation\">,<\/span> pi<span class=\"token punctuation\">,<\/span> log<br \/>\n<span class=\"token comment\"># \u5bfc\u5165tkinter\u5e93\u7684\u6240\u6709\u7ec4\u4ef6&#xff0c;\u7528\u4e8e\u521b\u5efa\u56fe\u5f62\u7a97\u53e3\u548c\u7ed8\u5236\u753b\u5e03<\/span><br \/>\n<span class=\"token keyword\">from<\/span> tkinter <span class=\"token keyword\">import<\/span> <span class=\"token operator\">*<\/span><\/p>\n<p><span class=\"token comment\"># &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u5168\u5c40\u5e38\u91cf\u914d\u7f6e\u533a &#8211; \u53ef\u76f4\u63a5\u4fee\u6539\u6570\u503c\u8c03\u6574\u7231\u5fc3\u6837\u5f0f &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<\/span><br \/>\nCANVAS_WIDTH <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">640<\/span>  <span class=\"token comment\"># \u753b\u5e03&#xff08;\u7a97\u53e3&#xff09;\u5bbd\u5ea6&#xff0c;\u5355\u4f4d&#xff1a;\u50cf\u7d20<\/span><br \/>\nCANVAS_HEIGHT <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">480<\/span>  <span class=\"token comment\"># \u753b\u5e03&#xff08;\u7a97\u53e3&#xff09;\u9ad8\u5ea6&#xff0c;\u5355\u4f4d&#xff1a;\u50cf\u7d20<\/span><br \/>\nCANVAS_CENTER_X <span class=\"token operator\">&#061;<\/span> CANVAS_WIDTH <span class=\"token operator\">\/<\/span> <span class=\"token number\">2<\/span>  <span class=\"token comment\"># \u753b\u5e03\u4e2d\u5fc3X\u8f74\u5750\u6807&#xff0c;\u8ba9\u7231\u5fc3\u5c45\u4e2d<\/span><br \/>\nCANVAS_CENTER_Y <span class=\"token operator\">&#061;<\/span> CANVAS_HEIGHT <span class=\"token operator\">\/<\/span> <span class=\"token number\">2<\/span>  <span class=\"token comment\"># \u753b\u5e03\u4e2d\u5fc3Y\u8f74\u5750\u6807&#xff0c;\u8ba9\u7231\u5fc3\u5c45\u4e2d<\/span><br \/>\nIMAGE_ENLARGE <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">11<\/span>  <span class=\"token comment\"># \u7231\u5fc3\u57fa\u7840\u7f29\u653e\u6bd4\u4f8b&#xff0c;\u6570\u503c\u8d8a\u5927\u7231\u5fc3\u8d8a\u5927<\/span><br \/>\nHEART_COLOR <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;#FFC0CB&#034;<\/span>  <span class=\"token comment\"># \u7231\u5fc3\u7c92\u5b50\u989c\u8272&#xff0c;16\u8fdb\u5236\u8272\u503c&#xff08;\u7c89\u8272&#xff09;<\/span><\/p>\n<p><span class=\"token comment\"># &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u6838\u5fc3\u5de5\u5177\u51fd\u6570 &#8211; \u5b9e\u73b0\u7231\u5fc3\u5750\u6807\u3001\u7c92\u5b50\u6269\u6563\u3001\u8df3\u52a8\u8282\u594f\u8ba1\u7b97 &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<\/span><br \/>\n<span class=\"token keyword\">def<\/span> <span class=\"token function\">heart_function<\/span><span class=\"token punctuation\">(<\/span>t<span class=\"token punctuation\">,<\/span> shrink_ratio<span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">float<\/span> <span class=\"token operator\">&#061;<\/span> IMAGE_ENLARGE<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token comment\"># \u6839\u636e\u7b1b\u5361\u5c14\u5fc3\u5f62\u516c\u5f0f&#xff0c;\u901a\u8fc7\u5f27\u5ea6t\u8ba1\u7b97\u7231\u5fc3\u5355\u4e2a\u5750\u6807\u70b9<\/span><br \/>\n    x <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">16<\/span> <span class=\"token operator\">*<\/span> <span class=\"token punctuation\">(<\/span>sin<span class=\"token punctuation\">(<\/span>t<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">**<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    y <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">13<\/span> <span class=\"token operator\">*<\/span> cos<span class=\"token punctuation\">(<\/span>t<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#8211;<\/span> <span class=\"token number\">5<\/span> <span class=\"token operator\">*<\/span> cos<span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span> <span class=\"token operator\">*<\/span> t<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#8211;<\/span> <span class=\"token number\">2<\/span> <span class=\"token operator\">*<\/span> cos<span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span> <span class=\"token operator\">*<\/span> t<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#8211;<\/span> cos<span class=\"token punctuation\">(<\/span><span class=\"token number\">4<\/span> <span class=\"token operator\">*<\/span> t<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token comment\"># \u7f29\u653e\u5750\u6807\u503c&#xff0c;\u9002\u914d\u753b\u5e03\u5c3a\u5bf8<\/span><br \/>\n    x <span class=\"token operator\">*&#061;<\/span> shrink_ratio<br \/>\n    y <span class=\"token operator\">*&#061;<\/span> shrink_ratio<br \/>\n    <span class=\"token comment\"># \u504f\u79fb\u5750\u6807&#xff0c;\u5c06\u7231\u5fc3\u4e2d\u5fc3\u79fb\u81f3\u753b\u5e03\u6b63\u4e2d\u5fc3<\/span><br \/>\n    x <span class=\"token operator\">&#043;&#061;<\/span> CANVAS_CENTER_X<br \/>\n    y <span class=\"token operator\">&#043;&#061;<\/span> CANVAS_CENTER_Y<br \/>\n    <span class=\"token comment\"># \u8f6c\u6362\u4e3a\u6574\u6570\u50cf\u7d20\u5750\u6807\u5e76\u8fd4\u56de<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token builtin\">int<\/span><span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token builtin\">int<\/span><span class=\"token punctuation\">(<\/span>y<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">scatter_inside<\/span><span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">,<\/span> beta<span class=\"token operator\">&#061;<\/span><span class=\"token number\">0.15<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token comment\"># \u8ba9\u57fa\u7840\u5750\u6807\u70b9\u5411\u753b\u5e03\u4e2d\u5fc3\u968f\u673a\u6269\u6563&#xff0c;\u751f\u6210\u7c92\u5b50\u6548\u679c<\/span><br \/>\n    <span class=\"token comment\"># beta&#xff1a;\u6269\u6563\u7cfb\u6570&#xff0c;\u503c\u8d8a\u5c0f\u7c92\u5b50\u8d8a\u5bc6\u96c6<\/span><br \/>\n    ratio_x <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&#8211;<\/span> beta <span class=\"token operator\">*<\/span> log<span class=\"token punctuation\">(<\/span>random<span class=\"token punctuation\">.<\/span>random<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    ratio_y <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&#8211;<\/span> beta <span class=\"token operator\">*<\/span> log<span class=\"token punctuation\">(<\/span>random<span class=\"token punctuation\">.<\/span>random<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token comment\"># \u8ba1\u7b97\u5411\u4e2d\u5fc3\u6269\u6563\u7684\u504f\u79fb\u91cf<\/span><br \/>\n    dx <span class=\"token operator\">&#061;<\/span> ratio_x <span class=\"token operator\">*<\/span> <span class=\"token punctuation\">(<\/span>x <span class=\"token operator\">&#8211;<\/span> CANVAS_CENTER_X<span class=\"token punctuation\">)<\/span><br \/>\n    dy <span class=\"token operator\">&#061;<\/span> ratio_y <span class=\"token operator\">*<\/span> <span class=\"token punctuation\">(<\/span>y <span class=\"token operator\">&#8211;<\/span> CANVAS_CENTER_Y<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> x <span class=\"token operator\">&#8211;<\/span> dx<span class=\"token punctuation\">,<\/span> y <span class=\"token operator\">&#8211;<\/span> dy<\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">shrink<\/span><span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">,<\/span> ratio<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token comment\"># \u8ba9\u5750\u6807\u70b9\u5411\u4e2d\u5fc3\u6536\u7f29&#xff0c;\u7528\u4e8e\u751f\u6210\u7231\u5fc3\u5916\u56f4\u5149\u6655\u6548\u679c<\/span><br \/>\n    <span class=\"token comment\"># \u8ba1\u7b97\u6536\u7f29\u529b&#xff0c;\u8ddd\u79bb\u4e2d\u5fc3\u8d8a\u8fdc\u6536\u7f29\u529b\u8d8a\u5927<\/span><br \/>\n    force <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span> <span class=\"token operator\">\/<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>x <span class=\"token operator\">&#8211;<\/span> CANVAS_CENTER_X<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">**<\/span> <span class=\"token number\">2<\/span> <span class=\"token operator\">&#043;<\/span> <span class=\"token punctuation\">(<\/span>y <span class=\"token operator\">&#8211;<\/span> CANVAS_CENTER_Y<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">**<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">**<\/span> <span class=\"token number\">0.6<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    dx <span class=\"token operator\">&#061;<\/span> ratio <span class=\"token operator\">*<\/span> force <span class=\"token operator\">*<\/span> <span class=\"token punctuation\">(<\/span>x <span class=\"token operator\">&#8211;<\/span> CANVAS_CENTER_X<span class=\"token punctuation\">)<\/span><br \/>\n    dy <span class=\"token operator\">&#061;<\/span> ratio <span class=\"token operator\">*<\/span> force <span class=\"token operator\">*<\/span> <span class=\"token punctuation\">(<\/span>y <span class=\"token operator\">&#8211;<\/span> CANVAS_CENTER_Y<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> x <span class=\"token operator\">&#8211;<\/span> dx<span class=\"token punctuation\">,<\/span> y <span class=\"token operator\">&#8211;<\/span> dy<\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">curve<\/span><span class=\"token punctuation\">(<\/span>p<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token comment\"># \u751f\u6210\u5468\u671f\u6027\u6b63\u5f26\u66f2\u7ebf&#xff0c;\u8fd4\u56de\u7f29\u653e\u6bd4\u4f8b&#xff0c;\u63a7\u5236\u7231\u5fc3\u8df3\u52a8\u8282\u594f<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token number\">2<\/span> <span class=\"token operator\">*<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span> <span class=\"token operator\">*<\/span> sin<span class=\"token punctuation\">(<\/span><span class=\"token number\">4<\/span> <span class=\"token operator\">*<\/span> p<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">\/<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span> <span class=\"token operator\">*<\/span> pi<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u7231\u5fc3\u6838\u5fc3\u7c7b &#8211; \u5c01\u88c5\u7231\u5fc3\u70b9\u6784\u5efa\u3001\u5e27\u8ba1\u7b97\u3001\u6e32\u67d3\u6240\u6709\u903b\u8f91 &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<\/span><br \/>\n<span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Heart<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">def<\/span> <span class=\"token function\">__init__<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> generate_frame<span class=\"token operator\">&#061;<\/span><span class=\"token number\">20<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token comment\"># \u521d\u59cb\u5316&#xff1a;\u521b\u5efa\u70b9\u96c6\u5408&#xff0c;\u9884\u8ba1\u7b97\u6240\u6709\u5e27\u7684\u7c92\u5b50\u6570\u636e<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>_points <span class=\"token operator\">&#061;<\/span> <span class=\"token builtin\">set<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u539f\u59cb\u7231\u5fc3\u8f6e\u5ed3\u70b9\u96c6\u5408&#xff08;\u65e0\u91cd\u590d&#xff09;<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>_edge_diffusion_points <span class=\"token operator\">&#061;<\/span> <span class=\"token builtin\">set<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u8fb9\u7f18\u6269\u6563\u70b9\u96c6\u5408&#xff08;\u67d4\u5316\u8fb9\u7f18&#xff09;<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>_center_diffusion_points <span class=\"token operator\">&#061;<\/span> <span class=\"token builtin\">set<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u4e2d\u5fc3\u6269\u6563\u70b9\u96c6\u5408&#xff08;\u586b\u5145\u5185\u90e8&#xff09;<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>all_points <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">}<\/span>  <span class=\"token comment\"># \u5b58\u50a8\u6240\u6709\u5e27\u6570\u636e&#xff1a;{\u5e27\u6570: [(x,y,\u7c92\u5b50\u5927\u5c0f), &#8230;]}<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>generate_frame <span class=\"token operator\">&#061;<\/span> generate_frame  <span class=\"token comment\"># \u4e00\u4e2a\u8df3\u52a8\u5468\u671f\u7684\u603b\u5e27\u6570<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>build<span class=\"token punctuation\">(<\/span><span class=\"token number\">2000<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u6784\u5efa2000\u4e2a\u539f\u59cb\u7231\u5fc3\u70b9&#xff0c;\u503c\u8d8a\u5927\u7c92\u5b50\u8d8a\u5bc6\u96c6<\/span><br \/>\n        <span class=\"token comment\"># \u9884\u8ba1\u7b97\u6240\u6709\u5e27\u6570\u636e&#xff0c;\u907f\u514d\u5b9e\u65f6\u8ba1\u7b97\u5361\u987f<\/span><br \/>\n        <span class=\"token keyword\">for<\/span> frame <span class=\"token keyword\">in<\/span> <span class=\"token builtin\">range<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">.<\/span>generate_frame<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            self<span class=\"token punctuation\">.<\/span>calc<span class=\"token punctuation\">(<\/span>frame<span class=\"token punctuation\">)<\/span><\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">build<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> number<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token comment\"># \u6784\u5efa\u539f\u59cb\u70b9\u3001\u8fb9\u7f18\u6269\u6563\u70b9\u3001\u4e2d\u5fc3\u6269\u6563\u70b9\u96c6\u5408<\/span><br \/>\n        <span class=\"token comment\"># 1. \u751f\u6210\u539f\u59cb\u7231\u5fc3\u8f6e\u5ed3\u70b9<\/span><br \/>\n        <span class=\"token keyword\">for<\/span> _ <span class=\"token keyword\">in<\/span> <span class=\"token builtin\">range<\/span><span class=\"token punctuation\">(<\/span>number<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            t <span class=\"token operator\">&#061;<\/span> random<span class=\"token punctuation\">.<\/span>uniform<span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">2<\/span> <span class=\"token operator\">*<\/span> pi<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u968f\u673a\u751f\u62100-2\u03c0\u5f27\u5ea6<\/span><br \/>\n            x<span class=\"token punctuation\">,<\/span> y <span class=\"token operator\">&#061;<\/span> heart_function<span class=\"token punctuation\">(<\/span>t<span class=\"token punctuation\">)<\/span><br \/>\n            self<span class=\"token punctuation\">.<\/span>_points<span class=\"token punctuation\">.<\/span>add<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token comment\"># 2. \u751f\u6210\u8fb9\u7f18\u6269\u6563\u70b9&#xff1a;\u6bcf\u4e2a\u539f\u59cb\u70b9\u751f\u62103\u4e2a&#xff0c;\u5c0f\u7cfb\u6570\u6269\u6563<\/span><br \/>\n        <span class=\"token keyword\">for<\/span> _x<span class=\"token punctuation\">,<\/span> _y <span class=\"token keyword\">in<\/span> <span class=\"token builtin\">list<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">.<\/span>_points<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token keyword\">for<\/span> _ <span class=\"token keyword\">in<\/span> <span class=\"token builtin\">range<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n                x<span class=\"token punctuation\">,<\/span> y <span class=\"token operator\">&#061;<\/span> scatter_inside<span class=\"token punctuation\">(<\/span>_x<span class=\"token punctuation\">,<\/span> _y<span class=\"token punctuation\">,<\/span> <span class=\"token number\">0.05<\/span><span class=\"token punctuation\">)<\/span><br \/>\n                self<span class=\"token punctuation\">.<\/span>_edge_diffusion_points<span class=\"token punctuation\">.<\/span>add<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token comment\"># 3. \u751f\u6210\u4e2d\u5fc3\u6269\u6563\u70b9&#xff1a;4000\u4e2a&#xff0c;\u5927\u7cfb\u6570\u6269\u6563&#xff0c;\u586b\u5145\u7231\u5fc3\u5185\u90e8<\/span><br \/>\n        point_list <span class=\"token operator\">&#061;<\/span> <span class=\"token builtin\">list<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">.<\/span>_points<span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">for<\/span> _ <span class=\"token keyword\">in<\/span> <span class=\"token builtin\">range<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">4000<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            x<span class=\"token punctuation\">,<\/span> y <span class=\"token operator\">&#061;<\/span> random<span class=\"token punctuation\">.<\/span>choice<span class=\"token punctuation\">(<\/span>point_list<span class=\"token punctuation\">)<\/span><br \/>\n            x<span class=\"token punctuation\">,<\/span> y <span class=\"token operator\">&#061;<\/span> scatter_inside<span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">,<\/span> <span class=\"token number\">0.17<\/span><span class=\"token punctuation\">)<\/span><br \/>\n            self<span class=\"token punctuation\">.<\/span>_center_diffusion_points<span class=\"token punctuation\">.<\/span>add<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>    <span class=\"token decorator annotation punctuation\">&#064;staticmethod<\/span><br \/>\n    <span class=\"token keyword\">def<\/span> <span class=\"token function\">calc_position<\/span><span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">,<\/span> ratio<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token comment\"># \u9759\u6001\u65b9\u6cd5&#xff1a;\u6839\u636e\u7f29\u653e\u6bd4\u4f8b\u8ba1\u7b97\u7c92\u5b50\u65b0\u5750\u6807&#xff0c;\u5b9e\u73b0\u52a8\u6001\u8df3\u52a8<\/span><br \/>\n        <span class=\"token comment\"># \u8ba1\u7b97\u8df3\u52a8\u529b&#xff0c;\u8ddd\u79bb\u4e2d\u5fc3\u8d8a\u8fdc&#xff0c;\u8df3\u52a8\u5e45\u5ea6\u8d8a\u5927<\/span><br \/>\n        force <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">1<\/span> <span class=\"token operator\">\/<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>x <span class=\"token operator\">&#8211;<\/span> CANVAS_CENTER_X<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">**<\/span> <span class=\"token number\">2<\/span> <span class=\"token operator\">&#043;<\/span> <span class=\"token punctuation\">(<\/span>y <span class=\"token operator\">&#8211;<\/span> CANVAS_CENTER_Y<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">**<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">**<\/span> <span class=\"token number\">0.520<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token comment\"># \u8ba1\u7b97\u504f\u79fb\u91cf&#xff0c;\u52a0\u5165\u8f7b\u5fae\u968f\u673a\u503c\u8ba9\u7c92\u5b50\u66f4\u81ea\u7136<\/span><br \/>\n        dx <span class=\"token operator\">&#061;<\/span> ratio <span class=\"token operator\">*<\/span> force <span class=\"token operator\">*<\/span> <span class=\"token punctuation\">(<\/span>x <span class=\"token operator\">&#8211;<\/span> CANVAS_CENTER_X<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#043;<\/span> random<span class=\"token punctuation\">.<\/span>randint<span class=\"token punctuation\">(<\/span><span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        dy <span class=\"token operator\">&#061;<\/span> ratio <span class=\"token operator\">*<\/span> force <span class=\"token operator\">*<\/span> <span class=\"token punctuation\">(<\/span>y <span class=\"token operator\">&#8211;<\/span> CANVAS_CENTER_Y<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#043;<\/span> random<span class=\"token punctuation\">.<\/span>randint<span class=\"token punctuation\">(<\/span><span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> x <span class=\"token operator\">&#8211;<\/span> dx<span class=\"token punctuation\">,<\/span> y <span class=\"token operator\">&#8211;<\/span> dy<\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">calc<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> generate_frame<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token comment\"># \u9884\u8ba1\u7b97\u6307\u5b9a\u5e27\u6570\u7684\u6240\u6709\u7c92\u5b50\u70b9\u6570\u636e&#xff08;\u7231\u5fc3&#043;\u5149\u6655&#xff09;<\/span><br \/>\n        ratio <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">10<\/span> <span class=\"token operator\">*<\/span> curve<span class=\"token punctuation\">(<\/span>generate_frame <span class=\"token operator\">\/<\/span> <span class=\"token number\">10<\/span> <span class=\"token operator\">*<\/span> pi<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u5f53\u524d\u5e27\u7f29\u653e\u6bd4\u4f8b<\/span><br \/>\n        <span class=\"token comment\"># \u8ba1\u7b97\u5f53\u524d\u5e27\u5149\u6655\u7684\u534a\u5f84\u548c\u7c92\u5b50\u6570\u91cf&#xff0c;\u968f\u8df3\u52a8\u8282\u594f\u53d8\u5316<\/span><br \/>\n        halo_radius <span class=\"token operator\">&#061;<\/span> <span class=\"token builtin\">int<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">4<\/span> <span class=\"token operator\">&#043;<\/span> <span class=\"token number\">6<\/span> <span class=\"token operator\">*<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span> <span class=\"token operator\">&#043;<\/span> curve<span class=\"token punctuation\">(<\/span>generate_frame <span class=\"token operator\">\/<\/span> <span class=\"token number\">10<\/span> <span class=\"token operator\">*<\/span> pi<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        halo_number <span class=\"token operator\">&#061;<\/span> <span class=\"token builtin\">int<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">3000<\/span> <span class=\"token operator\">&#043;<\/span> <span class=\"token number\">4000<\/span> <span class=\"token operator\">*<\/span> <span class=\"token builtin\">abs<\/span><span class=\"token punctuation\">(<\/span>curve<span class=\"token punctuation\">(<\/span>generate_frame <span class=\"token operator\">\/<\/span> <span class=\"token number\">10<\/span> <span class=\"token operator\">*<\/span> pi<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">**<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        all_points <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span>  <span class=\"token comment\"># \u5b58\u50a8\u5f53\u524d\u5e27\u6240\u6709\u7c92\u5b50\u70b9<\/span><\/p>\n<p>        <span class=\"token comment\"># 1. \u751f\u6210\u7231\u5fc3\u5916\u56f4\u5149\u6655\u7c92\u5b50\u70b9<\/span><br \/>\n        heart_halo_point <span class=\"token operator\">&#061;<\/span> <span class=\"token builtin\">set<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">for<\/span> _ <span class=\"token keyword\">in<\/span> <span class=\"token builtin\">range<\/span><span class=\"token punctuation\">(<\/span>halo_number<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            t <span class=\"token operator\">&#061;<\/span> random<span class=\"token punctuation\">.<\/span>uniform<span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">2<\/span> <span class=\"token operator\">*<\/span> pi<span class=\"token punctuation\">)<\/span><br \/>\n            x<span class=\"token punctuation\">,<\/span> y <span class=\"token operator\">&#061;<\/span> heart_function<span class=\"token punctuation\">(<\/span>t<span class=\"token punctuation\">,<\/span> shrink_ratio<span class=\"token operator\">&#061;<\/span><span class=\"token number\">11.6<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u8f7b\u5fae\u653e\u5927\u7231\u5fc3\u4f5c\u4e3a\u5149\u6655\u57fa\u7840<\/span><br \/>\n            x<span class=\"token punctuation\">,<\/span> y <span class=\"token operator\">&#061;<\/span> shrink<span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">,<\/span> halo_radius<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u6536\u7f29\u751f\u6210\u5149\u6655\u8f6e\u5ed3<\/span><br \/>\n            <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">not<\/span> <span class=\"token keyword\">in<\/span> heart_halo_point<span class=\"token punctuation\">:<\/span><br \/>\n                heart_halo_point<span class=\"token punctuation\">.<\/span>add<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n                x <span class=\"token operator\">&#043;&#061;<\/span> random<span class=\"token punctuation\">.<\/span>randint<span class=\"token punctuation\">(<\/span><span class=\"token operator\">&#8211;<\/span><span class=\"token number\">14<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">14<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u968f\u673a\u504f\u79fb&#xff0c;\u589e\u52a0\u5149\u6655\u6726\u80e7\u611f<\/span><br \/>\n                y <span class=\"token operator\">&#043;&#061;<\/span> random<span class=\"token punctuation\">.<\/span>randint<span class=\"token punctuation\">(<\/span><span class=\"token operator\">&#8211;<\/span><span class=\"token number\">14<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">14<\/span><span class=\"token punctuation\">)<\/span><br \/>\n                size <span class=\"token operator\">&#061;<\/span> random<span class=\"token punctuation\">.<\/span>choice<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u968f\u673a\u5149\u6655\u7c92\u5b50\u5927\u5c0f<\/span><br \/>\n                all_points<span class=\"token punctuation\">.<\/span>append<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">,<\/span> size<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>        <span class=\"token comment\"># 2. \u751f\u6210\u539f\u59cb\u7231\u5fc3\u7c92\u5b50\u70b9&#xff0c;\u6309\u5f53\u524d\u6bd4\u4f8b\u8df3\u52a8<\/span><br \/>\n        <span class=\"token keyword\">for<\/span> x<span class=\"token punctuation\">,<\/span> y <span class=\"token keyword\">in<\/span> self<span class=\"token punctuation\">.<\/span>_points<span class=\"token punctuation\">:<\/span><br \/>\n            x<span class=\"token punctuation\">,<\/span> y <span class=\"token operator\">&#061;<\/span> self<span class=\"token punctuation\">.<\/span>calc_position<span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">,<\/span> ratio<span class=\"token punctuation\">)<\/span><br \/>\n            size <span class=\"token operator\">&#061;<\/span> random<span class=\"token punctuation\">.<\/span>randint<span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><br \/>\n            all_points<span class=\"token punctuation\">.<\/span>append<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">,<\/span> size<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>        <span class=\"token comment\"># 3. \u751f\u6210\u8fb9\u7f18\u6269\u6563\u7c92\u5b50\u70b9&#xff0c;\u6309\u5f53\u524d\u6bd4\u4f8b\u8df3\u52a8<\/span><br \/>\n        <span class=\"token keyword\">for<\/span> x<span class=\"token punctuation\">,<\/span> y <span class=\"token keyword\">in<\/span> self<span class=\"token punctuation\">.<\/span>_edge_diffusion_points<span class=\"token punctuation\">:<\/span><br \/>\n            x<span class=\"token punctuation\">,<\/span> y <span class=\"token operator\">&#061;<\/span> self<span class=\"token punctuation\">.<\/span>calc_position<span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">,<\/span> ratio<span class=\"token punctuation\">)<\/span><br \/>\n            size <span class=\"token operator\">&#061;<\/span> random<span class=\"token punctuation\">.<\/span>randint<span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span><br \/>\n            all_points<span class=\"token punctuation\">.<\/span>append<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">,<\/span> size<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>        <span class=\"token comment\"># 4. \u751f\u6210\u4e2d\u5fc3\u6269\u6563\u7c92\u5b50\u70b9&#xff0c;\u6309\u5f53\u524d\u6bd4\u4f8b\u8df3\u52a8<\/span><br \/>\n        <span class=\"token keyword\">for<\/span> x<span class=\"token punctuation\">,<\/span> y <span class=\"token keyword\">in<\/span> self<span class=\"token punctuation\">.<\/span>_center_diffusion_points<span class=\"token punctuation\">:<\/span><br \/>\n            x<span class=\"token punctuation\">,<\/span> y <span class=\"token operator\">&#061;<\/span> self<span class=\"token punctuation\">.<\/span>calc_position<span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">,<\/span> ratio<span class=\"token punctuation\">)<\/span><br \/>\n            size <span class=\"token operator\">&#061;<\/span> random<span class=\"token punctuation\">.<\/span>randint<span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span><br \/>\n            all_points<span class=\"token punctuation\">.<\/span>append<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">,<\/span> size<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>        <span class=\"token comment\"># \u4fdd\u5b58\u5f53\u524d\u5e27\u6240\u6709\u7c92\u5b50\u70b9\u6570\u636e<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>all_points<span class=\"token punctuation\">[<\/span>generate_frame<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> all_points<\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">render<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> render_canvas<span class=\"token punctuation\">,<\/span> render_frame<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token comment\"># \u5c06\u6307\u5b9a\u5e27\u6570\u7684\u7c92\u5b50\u70b9\u7ed8\u5236\u5230\u753b\u5e03\u4e0a<\/span><br \/>\n        <span class=\"token comment\"># \u5faa\u73af\u53d6\u5e27&#xff0c;\u5b9e\u73b0\u65e0\u9650\u8df3\u52a8<\/span><br \/>\n        frame_points <span class=\"token operator\">&#061;<\/span> self<span class=\"token punctuation\">.<\/span>all_points<span class=\"token punctuation\">[<\/span>render_frame <span class=\"token operator\">%<\/span> self<span class=\"token punctuation\">.<\/span>generate_frame<span class=\"token punctuation\">]<\/span><br \/>\n        <span class=\"token comment\"># \u904d\u5386\u7c92\u5b50\u70b9&#xff0c;\u7ed8\u5236\u5b9e\u5fc3\u77e9\u5f62\u7c92\u5b50<\/span><br \/>\n        <span class=\"token keyword\">for<\/span> x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">,<\/span> size <span class=\"token keyword\">in<\/span> frame_points<span class=\"token punctuation\">:<\/span><br \/>\n            render_canvas<span class=\"token punctuation\">.<\/span>create_rectangle<span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">,<\/span> x <span class=\"token operator\">&#043;<\/span> size<span class=\"token punctuation\">,<\/span> y <span class=\"token operator\">&#043;<\/span> size<span class=\"token punctuation\">,<\/span> width<span class=\"token operator\">&#061;<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> fill<span class=\"token operator\">&#061;<\/span>HEART_COLOR<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u52a8\u6001\u7ed8\u5236\u5faa\u73af &#8211; \u9010\u5e27\u6e32\u67d3&#xff0c;\u8ba9\u7231\u5fc3\u52a8\u8d77\u6765 &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<\/span><br \/>\n<span class=\"token keyword\">def<\/span> <span class=\"token function\">draw<\/span><span class=\"token punctuation\">(<\/span>main<span class=\"token punctuation\">:<\/span> Tk<span class=\"token punctuation\">,<\/span> render_canvas<span class=\"token punctuation\">:<\/span> Canvas<span class=\"token punctuation\">,<\/span> render_heart<span class=\"token punctuation\">:<\/span> Heart<span class=\"token punctuation\">,<\/span> render_frame<span class=\"token operator\">&#061;<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    render_canvas<span class=\"token punctuation\">.<\/span>delete<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;all&#039;<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u6e05\u7a7a\u4e0a\u4e00\u5e27\u5185\u5bb9&#xff0c;\u907f\u514d\u91cd\u53e0<\/span><br \/>\n    render_heart<span class=\"token punctuation\">.<\/span>render<span class=\"token punctuation\">(<\/span>render_canvas<span class=\"token punctuation\">,<\/span> render_frame<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u6e32\u67d3\u5f53\u524d\u5e27\u7231\u5fc3<\/span><br \/>\n    <span class=\"token comment\"># 160\u6beb\u79d2\u540e\u9012\u5f52\u8c03\u7528&#xff0c;\u5b9e\u73b0\u6301\u7eed\u52a8\u6001\u5237\u65b0<\/span><br \/>\n    main<span class=\"token punctuation\">.<\/span>after<span class=\"token punctuation\">(<\/span><span class=\"token number\">160<\/span><span class=\"token punctuation\">,<\/span> draw<span class=\"token punctuation\">,<\/span> main<span class=\"token punctuation\">,<\/span> render_canvas<span class=\"token punctuation\">,<\/span> render_heart<span class=\"token punctuation\">,<\/span> render_frame <span class=\"token operator\">&#043;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u4e3b\u7a0b\u5e8f\u5165\u53e3 &#8211; \u6267\u884c\u6240\u6709\u903b\u8f91&#xff0c;\u542f\u52a8\u7a0b\u5e8f &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<\/span><br \/>\n<span class=\"token keyword\">if<\/span> __name__ <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token string\">&#039;__main__&#039;<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    root <span class=\"token operator\">&#061;<\/span> Tk<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u521b\u5efatkinter\u4e3b\u7a97\u53e3\u5bf9\u8c61<\/span><br \/>\n    root<span class=\"token punctuation\">.<\/span>title<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Python\u52a8\u6001\u8df3\u52a8\u7231\u5fc3 | \u60c5\u4eba\u8282\u4e13\u5c5e&#034;<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u8bbe\u7f6e\u7a97\u53e3\u6807\u9898<\/span><br \/>\n    <span class=\"token comment\"># \u521b\u5efa\u753b\u5e03&#xff0c;\u9ed1\u8272\u80cc\u666f&#xff0c;\u6307\u5b9a\u5bbd\u9ad8<\/span><br \/>\n    canvas <span class=\"token operator\">&#061;<\/span> Canvas<span class=\"token punctuation\">(<\/span>root<span class=\"token punctuation\">,<\/span> bg<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;black&#039;<\/span><span class=\"token punctuation\">,<\/span> height<span class=\"token operator\">&#061;<\/span>CANVAS_HEIGHT<span class=\"token punctuation\">,<\/span> width<span class=\"token operator\">&#061;<\/span>CANVAS_WIDTH<span class=\"token punctuation\">)<\/span><br \/>\n    canvas<span class=\"token punctuation\">.<\/span>pack<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u5c06\u753b\u5e03\u5e03\u5c40\u5230\u4e3b\u7a97\u53e3&#xff0c;\u4f7f\u5176\u663e\u793a<\/span><br \/>\n    heart <span class=\"token operator\">&#061;<\/span> Heart<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u521d\u59cb\u5316\u7231\u5fc3\u5bf9\u8c61<\/span><br \/>\n    draw<span class=\"token punctuation\">(<\/span>root<span class=\"token punctuation\">,<\/span> canvas<span class=\"token punctuation\">,<\/span> heart<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u542f\u52a8\u52a8\u6001\u7ed8\u5236\u5faa\u73af<\/span><br \/>\n    root<span class=\"token punctuation\">.<\/span>mainloop<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u8fdb\u5165\u4e3b\u4e8b\u4ef6\u5faa\u73af&#xff0c;\u4fdd\u6301\u7a97\u53e3\u663e\u793a<\/span><\/p>\n<h2>\u516d\u3001\u8be6\u7ec6\u8fd0\u884c\u6b65\u9aa4<\/h2>\n<p>\u7ed3\u5408\u4e0a\u8ff0\u7684\u73af\u5883\u51c6\u5907\u548c\u4ee3\u7801\u5c55\u793a&#xff0c;\u4ee5\u4e0b\u662f\u96f6\u57fa\u7840\u624b\u628a\u624b\u8fd0\u884c\u6b65\u9aa4&#xff0c;\u6309\u6b65\u9aa4\u64cd\u4f5c\u5373\u53ef\u96f6\u51fa\u9519\u8fd0\u884c\u51fa\u52a8\u6001\u7231\u5fc3\u6548\u679c&#xff1a;<\/p>\n<li>\u6309\u7167\u300c\u73af\u5883\u51c6\u5907\u300d\u6b65\u9aa4&#xff0c;\u5b8c\u6210Python\u89e3\u91ca\u5668\u548cPyCharm\u7f16\u8f91\u5668\u7684\u5b89\u88c5&#xff0c;\u5e76\u901a\u8fc7\u7ec8\u7aef\u9a8c\u8bc1\u73af\u5883\u914d\u7f6e\u6210\u529f&#xff1b;<\/li>\n<li>\u6253\u5f00PyCharm&#xff0c;\u65b0\u5efa\u7a7a\u767d\u9879\u76ee&#xff0c;\u518d\u53f3\u952e\u9879\u76ee\u76ee\u5f55\u65b0\u5efa\u540e\u7f00\u4e3a.py\u7684Python\u6587\u4ef6&#xff1b;<\/li>\n<li>\u5c06\u300c\u4ee3\u7801\u5c55\u793a\u300d\u90e8\u5206\u7684\u5b8c\u6574\u5e26\u6ce8\u91ca\u4ee3\u7801\u5168\u9009\u590d\u5236&#xff0c;\u7c98\u8d34\u5230\u65b0\u5efa\u7684Python\u6587\u4ef6\u4e2d&#xff0c;\u65e0\u9700\u4fee\u6539\u4efb\u4f55\u4ee3\u7801&#xff1b;<\/li>\n<li>\u627e\u5230PyCharm\u6587\u4ef6\u53f3\u4e0a\u89d2\u7684\u7eff\u8272\u4e09\u89d2\u8fd0\u884c\u6309\u94ae&#xff08;\u6216\u53f3\u952ePython\u6587\u4ef6&#xff0c;\u9009\u62e9\u300cRun \u6587\u4ef6\u540d\u300d&#xff09;&#xff0c;\u70b9\u51fb\u8fd0\u884c&#xff1b;<\/li>\n<li>\u7b49\u5f851-2\u79d2&#xff0c;\u7535\u8111\u684c\u9762\u4f1a\u5f39\u51fa\u52a8\u6001\u7231\u5fc3\u7684\u56fe\u5f62\u7a97\u53e3&#xff0c;\u5373\u53ef\u67e5\u770b\u6548\u679c&#xff1b;<\/li>\n<li>\u60f3\u8981\u505c\u6b62\u7a0b\u5e8f\u3001\u5173\u95ed\u7231\u5fc3\u7a97\u53e3&#xff0c;\u76f4\u63a5\u70b9\u51fb\u56fe\u5f62\u7a97\u53e3\u53f3\u4e0a\u89d2\u7684\u5173\u95ed\u6309\u94ae&#xff08;\u00d7&#xff09; \u5373\u53ef\u3002<\/li>\n<h2>\u4e03\u3001\u603b\u7ed3<\/h2>\n<p>\u672c\u6b21\u7684\u52a8\u6001\u8df3\u52a8\u7231\u5fc3\u6848\u4f8b&#xff0c;\u662fPython\u57fa\u7840\u8bed\u6cd5&#043;\u7ecf\u5178\u6570\u5b66\u516c\u5f0f&#043;tkinter GUI\u7684\u7efc\u5408\u5165\u95e8\u5c0f\u6848\u4f8b&#xff0c;\u5168\u7a0b\u4ec5\u4f7f\u7528Python\u5185\u7f6e\u6807\u51c6\u5e93&#xff0c;\u65e0\u4efb\u4f55\u590d\u6742\u7b2c\u4e09\u65b9\u4f9d\u8d56&#xff0c;\u65e2\u8d34\u5408\u60c5\u4eba\u8282\u70ed\u70b9&#xff0c;\u80fd\u901a\u8fc7\u4ee3\u7801\u5236\u9020\u4e13\u5c5e\u6d6a\u6f2b&#xff0c;\u53c8\u975e\u5e38\u9002\u5408Python\u96f6\u57fa\u7840\u65b0\u624b\u7ec3\u624b\u3002<\/p>\n<p>\u901a\u8fc7\u5b66\u4e60\u672c\u6848\u4f8b&#xff0c;\u4e0d\u4ec5\u80fd\u638c\u63e1random\u3001math\u3001tkinter\u4e09\u4e2a\u6838\u5fc3\u5185\u7f6e\u5e93\u7684\u57fa\u7840\u4f7f\u7528\u65b9\u6cd5&#xff0c;\u8fd8\u80fd\u7406\u89e3\u7b1b\u5361\u5c14\u5fc3\u5f62\u516c\u5f0f\u7684\u5e94\u7528\u3001\u6b63\u5f26\u66f2\u7ebf\u5b9e\u73b0\u5468\u671f\u6027\u52a8\u6001\u3001\u9762\u5411\u5bf9\u8c61\u7684\u4ee3\u7801\u5c01\u88c5\u601d\u60f3\u3001tkinter\u9010\u5e27\u6e32\u67d3\u5b9e\u73b0\u52a8\u6001\u56fe\u5f62\u7b49\u5173\u952e\u77e5\u8bc6\u70b9&#xff0c;\u8fd9\u4e9b\u77e5\u8bc6\u70b9\u53ef\u76f4\u63a5\u8fc1\u79fb\u5230\u5176\u4ed6Python\u8da3\u5473\u5c0f\u6848\u4f8b\u4e2d&#xff0c;\u6bd4\u5982\u52a8\u6001\u70df\u82b1\u3001\u56fe\u5f62\u7ed8\u5236\u3001\u7b80\u5355GUI\u5c0f\u5de5\u5177\u7b49\u3002<\/p>\n<p>\u672c\u6848\u4f8b\u4e5f\u662f\u535a\u4e3b\u300cPython\u8da3\u5473\u4ee3\u7801\u5927\u5168\u300d\u4e13\u680f\u7684\u7b2c\u4e00\u7bc7\u5185\u5bb9&#xff0c;\u540e\u7eed\u4e13\u680f\u4f1a\u6301\u7eed\u66f4\u65b0\u66f4\u591a\u77ed\u5c0f\u7cbe\u608d\u3001\u65b0\u624b\u80fd\u4e00\u952e\u8fd0\u884c\u7684Python\u8da3\u5473\u4ee3\u7801&#xff0c;\u5305\u62ec\u722c\u866b\u8da3\u73a9\u3001\u81ea\u52a8\u5316\u5c0f\u5de5\u5177\u3001\u4e00\u884c\u4ee3\u7801\u6574\u6d3b\u3001\u6570\u636e\u53ef\u89c6\u5316\u5c0f\u6848\u4f8b\u7b49&#xff0c;\u8ba9\u5927\u5bb6\u5728\u73a9\u4ee3\u7801\u7684\u8fc7\u7a0b\u4e2d&#xff0c;\u8f7b\u677e\u63d0\u5347Python\u7f16\u7a0b\u80fd\u529b\u3002<\/p>\n<p>\u5982\u679c\u89c9\u5f97\u8fd9\u4e2a\u6848\u4f8b\u6709\u8da3\u3001\u6709\u6536\u83b7&#xff0c;\u6b22\u8fce\u5173\u6ce8\u535a\u4e3b&#xff0c;\u540e\u7eed\u66f4\u591aPython\u8da3\u5473\u5185\u5bb9\u4e0d\u8ff7\u8def&#xff01;\u6700\u540e\u63d0\u524d\u795d\u5927\u5bb6\u60c5\u4eba\u8282\u5feb\u4e50&#xff0c;\u7528\u4ee3\u7801\u4e66\u5199\u7684\u6d6a\u6f2b&#xff0c;\u6c38\u8fdc\u6709\u7740\u72ec\u5c5e\u4e8e\u7a0b\u5e8f\u5458\u7684\u6e29\u5ea6\u548c\u5fc3\u610f&#xff5e;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9a6c\u4e0a\u5c31\u662f\u60c5\u4eba\u8282&#xff0c;\u7a0b\u5e8f\u5458\u7684\u6d6a\u6f2b\u4ece\u4e00\u884c\u884c\u4ee3\u7801\u5f00\u59cb&#xff01;\u4eca\u5929\u5206\u4eab\u4e00\u6b3e\u7eaf Python \u5185\u7f6e\u5e93\u5b9e\u73b0\u7684\u52a8\u6001\u8df3\u52a8\u7231\u5fc3&#xff0c;\u65e0\u9700\u590d\u6742\u7b2c\u4e09\u65b9\u4f9d\u8d56&#xff0c;\u9ed1\u8272\u80cc\u666f\u642d\u914d\u7c92\u5b50\u5316\u7231\u5fc3&#xff0c;\u81ea\u5e26\u81ea\u7136\u7684\u8df3\u52a8\u8282\u594f\u548c\u67d4\u548c\u5149\u6655&#xff0c;\u65e2\u9002\u5408\u9001\u7ed9\u5fc3\u4eea\u7684\u4eba\u5236\u9020\u60ca\u559c&#xff0c;\u4e5f\u80fd\u4f5c\u4e3a Python \u57fa\u7840\u7ec3\u624b\u6848\u4f8b\u3002\u672c\u6587\u5168\u7a0b\u4fdd\u59c6\u7ea7\u6587\u672c\u89e3\u6790  \u4ee3\u7801\u6ce8\u91ca\u53cc\u4fdd\u969c&#xff0c;\u4ece\u73af\u5883\u642d\u5efa\u5230\u4ee3\u7801\u903b\u8f91\u9010\u5b57\u62c6\u89e3&#xff0c;\u7eaf\u65b0\u624b\u4e5f\u80fd\u8ddf\u7740\u4e00\u6b65\u6b65\u5b9e\u73b0&#xff0c;<\/p>\n","protected":false},"author":2,"featured_media":72096,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7586,7585,7583,7584,81,5936,190],"topic":[],"class_list":["post-72098","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-7586","tag-7585","tag-7583","tag-7584","tag-python","tag-tkinter","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python \u7ed8\u5236\u52a8\u6001\u8df3\u52a8\u7231\u5fc3\uff5c\u60c5\u4eba\u8282\u4e13\u5c5e\u6d6a\u6f2b\u4ee3\u7801\uff0c\u65b0\u624b\u96f6\u57fa\u7840\u4e5f\u80fd\u4e0a\u624b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/72098.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python \u7ed8\u5236\u52a8\u6001\u8df3\u52a8\u7231\u5fc3\uff5c\u60c5\u4eba\u8282\u4e13\u5c5e\u6d6a\u6f2b\u4ee3\u7801\uff0c\u65b0\u624b\u96f6\u57fa\u7840\u4e5f\u80fd\u4e0a\u624b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u9a6c\u4e0a\u5c31\u662f\u60c5\u4eba\u8282&#xff0c;\u7a0b\u5e8f\u5458\u7684\u6d6a\u6f2b\u4ece\u4e00\u884c\u884c\u4ee3\u7801\u5f00\u59cb&#xff01;\u4eca\u5929\u5206\u4eab\u4e00\u6b3e\u7eaf Python \u5185\u7f6e\u5e93\u5b9e\u73b0\u7684\u52a8\u6001\u8df3\u52a8\u7231\u5fc3&#xff0c;\u65e0\u9700\u590d\u6742\u7b2c\u4e09\u65b9\u4f9d\u8d56&#xff0c;\u9ed1\u8272\u80cc\u666f\u642d\u914d\u7c92\u5b50\u5316\u7231\u5fc3&#xff0c;\u81ea\u5e26\u81ea\u7136\u7684\u8df3\u52a8\u8282\u594f\u548c\u67d4\u548c\u5149\u6655&#xff0c;\u65e2\u9002\u5408\u9001\u7ed9\u5fc3\u4eea\u7684\u4eba\u5236\u9020\u60ca\u559c&#xff0c;\u4e5f\u80fd\u4f5c\u4e3a Python \u57fa\u7840\u7ec3\u624b\u6848\u4f8b\u3002\u672c\u6587\u5168\u7a0b\u4fdd\u59c6\u7ea7\u6587\u672c\u89e3\u6790 \u4ee3\u7801\u6ce8\u91ca\u53cc\u4fdd\u969c&#xff0c;\u4ece\u73af\u5883\u642d\u5efa\u5230\u4ee3\u7801\u903b\u8f91\u9010\u5b57\u62c6\u89e3&#xff0c;\u7eaf\u65b0\u624b\u4e5f\u80fd\u8ddf\u7740\u4e00\u6b65\u6b65\u5b9e\u73b0&#xff0c;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/72098.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-04T13:56:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260204135652-698350242fd69.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/72098.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/72098.html\",\"name\":\"Python \u7ed8\u5236\u52a8\u6001\u8df3\u52a8\u7231\u5fc3\uff5c\u60c5\u4eba\u8282\u4e13\u5c5e\u6d6a\u6f2b\u4ee3\u7801\uff0c\u65b0\u624b\u96f6\u57fa\u7840\u4e5f\u80fd\u4e0a\u624b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-04T13:56:57+00:00\",\"dateModified\":\"2026-02-04T13:56:57+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/72098.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/72098.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/72098.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python \u7ed8\u5236\u52a8\u6001\u8df3\u52a8\u7231\u5fc3\uff5c\u60c5\u4eba\u8282\u4e13\u5c5e\u6d6a\u6f2b\u4ee3\u7801\uff0c\u65b0\u624b\u96f6\u57fa\u7840\u4e5f\u80fd\u4e0a\u624b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python \u7ed8\u5236\u52a8\u6001\u8df3\u52a8\u7231\u5fc3\uff5c\u60c5\u4eba\u8282\u4e13\u5c5e\u6d6a\u6f2b\u4ee3\u7801\uff0c\u65b0\u624b\u96f6\u57fa\u7840\u4e5f\u80fd\u4e0a\u624b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/72098.html","og_locale":"zh_CN","og_type":"article","og_title":"Python \u7ed8\u5236\u52a8\u6001\u8df3\u52a8\u7231\u5fc3\uff5c\u60c5\u4eba\u8282\u4e13\u5c5e\u6d6a\u6f2b\u4ee3\u7801\uff0c\u65b0\u624b\u96f6\u57fa\u7840\u4e5f\u80fd\u4e0a\u624b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u9a6c\u4e0a\u5c31\u662f\u60c5\u4eba\u8282&#xff0c;\u7a0b\u5e8f\u5458\u7684\u6d6a\u6f2b\u4ece\u4e00\u884c\u884c\u4ee3\u7801\u5f00\u59cb&#xff01;\u4eca\u5929\u5206\u4eab\u4e00\u6b3e\u7eaf Python \u5185\u7f6e\u5e93\u5b9e\u73b0\u7684\u52a8\u6001\u8df3\u52a8\u7231\u5fc3&#xff0c;\u65e0\u9700\u590d\u6742\u7b2c\u4e09\u65b9\u4f9d\u8d56&#xff0c;\u9ed1\u8272\u80cc\u666f\u642d\u914d\u7c92\u5b50\u5316\u7231\u5fc3&#xff0c;\u81ea\u5e26\u81ea\u7136\u7684\u8df3\u52a8\u8282\u594f\u548c\u67d4\u548c\u5149\u6655&#xff0c;\u65e2\u9002\u5408\u9001\u7ed9\u5fc3\u4eea\u7684\u4eba\u5236\u9020\u60ca\u559c&#xff0c;\u4e5f\u80fd\u4f5c\u4e3a Python \u57fa\u7840\u7ec3\u624b\u6848\u4f8b\u3002\u672c\u6587\u5168\u7a0b\u4fdd\u59c6\u7ea7\u6587\u672c\u89e3\u6790 \u4ee3\u7801\u6ce8\u91ca\u53cc\u4fdd\u969c&#xff0c;\u4ece\u73af\u5883\u642d\u5efa\u5230\u4ee3\u7801\u903b\u8f91\u9010\u5b57\u62c6\u89e3&#xff0c;\u7eaf\u65b0\u624b\u4e5f\u80fd\u8ddf\u7740\u4e00\u6b65\u6b65\u5b9e\u73b0&#xff0c;","og_url":"https:\/\/www.wsisp.com\/helps\/72098.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-04T13:56:57+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260204135652-698350242fd69.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"9 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/72098.html","url":"https:\/\/www.wsisp.com\/helps\/72098.html","name":"Python \u7ed8\u5236\u52a8\u6001\u8df3\u52a8\u7231\u5fc3\uff5c\u60c5\u4eba\u8282\u4e13\u5c5e\u6d6a\u6f2b\u4ee3\u7801\uff0c\u65b0\u624b\u96f6\u57fa\u7840\u4e5f\u80fd\u4e0a\u624b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-04T13:56:57+00:00","dateModified":"2026-02-04T13:56:57+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/72098.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/72098.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/72098.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Python \u7ed8\u5236\u52a8\u6001\u8df3\u52a8\u7231\u5fc3\uff5c\u60c5\u4eba\u8282\u4e13\u5c5e\u6d6a\u6f2b\u4ee3\u7801\uff0c\u65b0\u624b\u96f6\u57fa\u7840\u4e5f\u80fd\u4e0a\u624b"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/72098","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=72098"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/72098\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/72096"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=72098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=72098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=72098"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=72098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}