{"id":941097,"date":"2024-12-26T21:22:45","date_gmt":"2024-12-26T13:22:45","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/941097.html"},"modified":"2024-12-26T21:22:48","modified_gmt":"2024-12-26T13:22:48","slug":"%e5%a6%82%e4%bd%95%e5%88%b6%e4%bd%9cpython%e5%ba%93","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/941097.html","title":{"rendered":"\u5982\u4f55\u5236\u4f5cpython\u5e93"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25075451\/0ed5b6a8-3af5-4e96-ae9d-12d4db24f992.webp\" alt=\"\u5982\u4f55\u5236\u4f5cpython\u5e93\" \/><\/p>\n<p><p> <strong>\u8981\u5236\u4f5cPython\u5e93\uff0c\u4f60\u9700\u8981<\/strong>\uff1a<strong>\u660e\u786e\u5e93\u7684\u529f\u80fd\u3001\u7f16\u5199\u6a21\u5757\u4ee3\u7801\u3001\u521b\u5efasetup.py\u6587\u4ef6\u3001\u7f16\u5199\u6587\u6863\u3001\u53d1\u5e03\u5230PyPI<\/strong>\u3002\u660e\u786e\u5e93\u7684\u529f\u80fd\u662f\u7b2c\u4e00\u6b65\uff0c\u4f60\u9700\u8981\u6e05\u6670\u5730\u5b9a\u4e49\u5e93\u7684\u7528\u9014\u548c\u76ee\u6807\u7528\u6237\u3002\u63a5\u4e0b\u6765\uff0c\u7f16\u5199\u6a21\u5757\u4ee3\u7801\u662f\u5c06\u4f60\u7684\u529f\u80fd\u5b9e\u73b0\u4e3aPython\u4ee3\u7801\uff0c\u5e76\u7ec4\u7ec7\u6210\u53ef\u91cd\u7528\u7684\u7ed3\u6784\u3002\u521b\u5efasetup.py\u6587\u4ef6\u662f\u4e3a\u4e86\u5b9a\u4e49\u5e93\u7684\u5143\u6570\u636e\uff0c\u5982\u540d\u79f0\u3001\u7248\u672c\u3001\u4f9d\u8d56\u9879\u7b49\u3002\u7f16\u5199\u6587\u6863\u5bf9\u4e8e\u7528\u6237\u7406\u89e3\u548c\u4f7f\u7528\u4f60\u7684\u5e93\u81f3\u5173\u91cd\u8981\uff0c\u786e\u4fdd\u6587\u6863\u6613\u4e8e\u9605\u8bfb\u5e76\u5305\u542b\u793a\u4f8b\u4ee3\u7801\u3002\u6700\u540e\uff0c\u5c06\u4f60\u7684\u5e93\u53d1\u5e03\u5230Python Package Index (PyPI)\uff0c\u4f7f\u5176\u4ed6\u5f00\u53d1\u8005\u53ef\u4ee5\u8f7b\u677e\u5b89\u88c5\u548c\u4f7f\u7528\u4f60\u7684\u5e93\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u660e\u786e\u5e93\u7684\u529f\u80fd<\/h3>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u5236\u4f5cPython\u5e93\u4e4b\u524d\uff0c\u660e\u786e\u5e93\u7684\u529f\u80fd\u662f\u81f3\u5173\u91cd\u8981\u7684\u3002\u8fd9\u4e00\u6b65\u5e2e\u52a9\u4f60\u7406\u6e05\u601d\u8def\uff0c\u786e\u5b9a\u5e93\u7684\u7528\u9014\u548c\u76ee\u6807\u7528\u6237\u3002\u8003\u8651\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u529f\u80fd\u5b9a\u4e49<\/strong>\uff1a\u660e\u786e\u5e93\u7684\u6838\u5fc3\u529f\u80fd\u662f\u4ec0\u4e48\u3002\u4f60\u9700\u8981\u6e05\u6670\u5730\u77e5\u9053\u8fd9\u4e2a\u5e93\u662f\u7528\u6765\u89e3\u51b3\u4ec0\u4e48\u95ee\u9898\u7684\uff0c\u5e76\u786e\u4fdd\u5b83\u6ee1\u8db3\u76ee\u6807\u7528\u6237\u7684\u9700\u6c42\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u6b63\u5728\u5f00\u53d1\u4e00\u4e2a\u6570\u636e\u5904\u7406\u5e93\uff0c\u660e\u786e\u5b83\u662f\u4e13\u6ce8\u4e8e\u6570\u636e\u6e05\u6d17\u3001\u8f6c\u6362\u8fd8\u662f\u5206\u6790\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u76ee\u6807\u7528\u6237<\/strong>\uff1a\u786e\u5b9a\u8c01\u5c06\u4f7f\u7528\u4f60\u7684\u5e93\uff0c\u4ee5\u53ca\u4ed6\u4eec\u7684\u9700\u6c42\u548c\u6280\u672f\u6c34\u5e73\u3002\u8fd9\u6709\u52a9\u4e8e\u4f60\u5728\u8bbe\u8ba1\u548c\u5b9e\u73b0\u529f\u80fd\u65f6\u8003\u8651\u7528\u6237\u4f53\u9a8c\u548c\u6613\u7528\u6027\u3002\u5982\u679c\u4f60\u7684\u5e93\u662f\u9762\u5411\u521d\u5b66\u8005\u7684\uff0c\u786e\u4fdd\u6587\u6863\u548c\u4ee3\u7801\u793a\u4f8b\u7b80\u5355\u660e\u4e86\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u660e\u786e\u5e93\u7684\u529f\u80fd\u6709\u52a9\u4e8e\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u4fdd\u6301\u4e13\u6ce8\uff0c\u907f\u514d\u8fc7\u591a\u7684\u529f\u80fd\u81a8\u80c0\uff0c\u5e76\u786e\u4fdd\u6700\u7ec8\u4ea7\u54c1\u6ee1\u8db3\u7528\u6237\u9700\u6c42\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u7f16\u5199\u6a21\u5757\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u4e00\u65e6\u660e\u786e\u4e86\u5e93\u7684\u529f\u80fd\uff0c\u4e0b\u4e00\u6b65\u5c31\u662f\u7f16\u5199\u6a21\u5757\u4ee3\u7801\u3002\u8fd9\u4e00\u8fc7\u7a0b\u6d89\u53ca\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4ee3\u7801\u7ec4\u7ec7<\/strong>\uff1a\u5c06\u529f\u80fd\u5206\u89e3\u4e3a\u591a\u4e2a\u6a21\u5757\u548c\u51fd\u6570\uff0c\u4ee5\u4fbf\u4e8e\u7ba1\u7406\u548c\u4f7f\u7528\u3002\u5c06\u76f8\u5173\u7684\u529f\u80fd\u7ec4\u5408\u5728\u4e00\u8d77\uff0c\u5f62\u6210\u6a21\u5757\uff0c\u786e\u4fdd\u4ee3\u7801\u7684\u53ef\u91cd\u7528\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u5c06\u6570\u636e\u5904\u7406\u529f\u80fd\u653e\u5728\u4e00\u4e2a\u6a21\u5757\u4e2d\uff0c\u6570\u636e\u53ef\u89c6\u5316\u529f\u80fd\u653e\u5728\u53e6\u4e00\u4e2a\u6a21\u5757\u4e2d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7f16\u7801\u5b9e\u8df5<\/strong>\uff1a\u9075\u5faa\u826f\u597d\u7684\u7f16\u7801\u5b9e\u8df5\uff0c\u786e\u4fdd\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002\u4f7f\u7528\u6e05\u6670\u7684\u53d8\u91cf\u540d\u3001\u51fd\u6570\u540d\u548c\u6ce8\u91ca\uff0c\u4ee5\u4fbf\u5176\u4ed6\u5f00\u53d1\u8005\u53ef\u4ee5\u8f7b\u677e\u7406\u89e3\u4f60\u7684\u4ee3\u7801\u3002\u9075\u5faaPEP 8\u7f16\u7801\u6807\u51c6\uff0c\u786e\u4fdd\u4ee3\u7801\u98ce\u683c\u7684\u4e00\u81f4\u6027\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6d4b\u8bd5<\/strong>\uff1a\u7f16\u5199\u5355\u5143\u6d4b\u8bd5\u4ee5\u9a8c\u8bc1\u4ee3\u7801\u7684\u6b63\u786e\u6027\u548c\u9c81\u68d2\u6027\u3002\u6d4b\u8bd5\u786e\u4fdd\u4f60\u7684\u4ee3\u7801\u5728\u5404\u79cd\u60c5\u51b5\u4e0b\u90fd\u80fd\u6b63\u5e38\u5de5\u4f5c\uff0c\u5e76\u5e2e\u52a9\u4f60\u5728\u5c06\u6765\u8fdb\u884c\u4fee\u6539\u65f6\u5feb\u901f\u53d1\u73b0\u6f5c\u5728\u7684\u95ee\u9898\u3002\u4f7f\u7528pytest\u6216unittest\u7b49\u6d4b\u8bd5\u6846\u67b6\u6765\u7f16\u5199\u548c\u8fd0\u884c\u6d4b\u8bd5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u521b\u5efasetup.py\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u521b\u5efasetup.py\u6587\u4ef6\u662f\u5236\u4f5cPython\u5e93\u7684\u91cd\u8981\u4e00\u6b65\uff0c\u5b83\u5b9a\u4e49\u4e86\u5e93\u7684\u5143\u6570\u636e\u548c\u5b89\u88c5\u4fe1\u606f\u3002\u4ee5\u4e0b\u662f\u521b\u5efasetup.py\u6587\u4ef6\u7684\u4e00\u4e9b\u5173\u952e\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5143\u6570\u636e\u5b9a\u4e49<\/strong>\uff1a\u5728setup.py\u6587\u4ef6\u4e2d\u5b9a\u4e49\u5e93\u7684\u540d\u79f0\u3001\u7248\u672c\u3001\u4f5c\u8005\u4fe1\u606f\u3001\u63cf\u8ff0\u7b49\u3002\u8fd9\u4e9b\u4fe1\u606f\u5c06\u663e\u793a\u5728PyPI\u4e0a\uff0c\u5e2e\u52a9\u7528\u6237\u4e86\u89e3\u4f60\u7684\u5e93\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from setuptools import setup, find_packages<\/p>\n<p>setup(<\/p>\n<p>    name=&#39;my_python_library&#39;,<\/p>\n<p>    version=&#39;0.1.0&#39;,<\/p>\n<p>    author=&#39;Your Name&#39;,<\/p>\n<p>    author_em<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>l=&#39;your.email@example.com&#39;,<\/p>\n<p>    description=&#39;A brief description of your library&#39;,<\/p>\n<p>    packages=find_packages(),<\/p>\n<p>    install_requires=[&#39;numpy&#39;, &#39;pandas&#39;],  # \u5217\u51fa\u4f9d\u8d56\u7684\u5e93<\/p>\n<p>)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f9d\u8d56\u7ba1\u7406<\/strong>\uff1a\u6307\u5b9a\u5e93\u7684\u4f9d\u8d56\u9879\uff0c\u4ee5\u786e\u4fdd\u7528\u6237\u5728\u5b89\u88c5\u65f6\u81ea\u52a8\u83b7\u53d6\u6240\u9700\u7684\u5e93\u3002\u5728install_requires\u53c2\u6570\u4e2d\u5217\u51fa\u6240\u6709\u4f9d\u8d56\u7684\u5e93\u548c\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5165\u53e3\u70b9<\/strong>\uff1a\u5982\u679c\u4f60\u7684\u5e93\u5305\u542b\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u53ef\u4ee5\u5728setup.py\u4e2d\u5b9a\u4e49\u5165\u53e3\u70b9\u3002\u8fd9\u4f7f\u5f97\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u76f4\u63a5\u8c03\u7528\u4f60\u7684\u5de5\u5177\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u7f16\u5199\u6587\u6863<\/h3>\n<\/p>\n<p><p>\u7f16\u5199\u6587\u6863\u662f\u5236\u4f5cPython\u5e93\u7684\u91cd\u8981\u7ec4\u6210\u90e8\u5206\uff0c\u5b83\u5e2e\u52a9\u7528\u6237\u7406\u89e3\u548c\u4f7f\u7528\u4f60\u7684\u5e93\u3002\u786e\u4fdd\u6587\u6863\u5185\u5bb9\u4e30\u5bcc\u3001\u7ed3\u6784\u6e05\u6670\uff0c\u5305\u542b\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u6307\u5357<\/strong>\uff1a\u63d0\u4f9b\u8be6\u7ec6\u7684\u5b89\u88c5\u6b65\u9aa4\uff0c\u5305\u62ec\u5982\u4f55\u901a\u8fc7pip\u5b89\u88c5\u5e93\uff0c\u4ee5\u53ca\u4efb\u4f55\u989d\u5916\u7684\u914d\u7f6e\u6b65\u9aa4\u3002\u786e\u4fdd\u7528\u6237\u80fd\u591f\u987a\u5229\u5b89\u88c5\u548c\u4f7f\u7528\u4f60\u7684\u5e93\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u793a\u4f8b<\/strong>\uff1a\u63d0\u4f9b\u4ee3\u7801\u793a\u4f8b\u548c\u7528\u4f8b\uff0c\u5c55\u793a\u5e93\u7684\u529f\u80fd\u548c\u7528\u6cd5\u3002\u793a\u4f8b\u4ee3\u7801\u5e94\u6db5\u76d6\u5e93\u7684\u6838\u5fc3\u529f\u80fd\uff0c\u5e2e\u52a9\u7528\u6237\u5feb\u901f\u4e0a\u624b\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>API\u6587\u6863<\/strong>\uff1a\u8be6\u7ec6\u63cf\u8ff0\u5e93\u4e2d\u6bcf\u4e2a\u6a21\u5757\u3001\u7c7b\u548c\u51fd\u6570\u7684\u529f\u80fd\u3001\u53c2\u6570\u548c\u8fd4\u56de\u503c\u3002\u4f7f\u7528Sphinx\u7b49\u5de5\u5177\u81ea\u52a8\u751f\u6210API\u6587\u6863\uff0c\u786e\u4fdd\u6587\u6863\u4e0e\u4ee3\u7801\u4fdd\u6301\u4e00\u81f4\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5e38\u89c1\u95ee\u9898\u89e3\u7b54<\/strong>\uff1a\u5217\u51fa\u7528\u6237\u53ef\u80fd\u9047\u5230\u7684\u95ee\u9898\u53ca\u5176\u89e3\u51b3\u65b9\u6848\uff0c\u5e2e\u52a9\u7528\u6237\u5feb\u901f\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u53d1\u5e03\u5230PyPI<\/h3>\n<\/p>\n<p><p>\u5c06\u4f60\u7684Python\u5e93\u53d1\u5e03\u5230Python Package Index (PyPI) \u662f\u6700\u540e\u4e00\u6b65\uff0c\u5b83\u5141\u8bb8\u5176\u4ed6\u5f00\u53d1\u8005\u8f7b\u677e\u5b89\u88c5\u548c\u4f7f\u7528\u4f60\u7684\u5e93\u3002\u4ee5\u4e0b\u662f\u53d1\u5e03\u8fc7\u7a0b\u7684\u5173\u952e\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6ce8\u518cPyPI\u8d26\u53f7<\/strong>\uff1a\u5728PyPI\u7f51\u7ad9\u4e0a\u6ce8\u518c\u4e00\u4e2a\u8d26\u6237\uff0c\u5e76\u83b7\u5f97API token\uff0c\u4ee5\u4fbf\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u548c\u53d1\u5e03\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6253\u5305\u5e93<\/strong>\uff1a\u4f7f\u7528setuptools\u6253\u5305\u4f60\u7684\u5e93\uff0c\u751f\u6210\u53ef\u5206\u53d1\u7684\u538b\u7f29\u5305\u548cwheel\u6587\u4ef6\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python setup.py sdist bdist_wheel<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4e0a\u4f20\u5230PyPI<\/strong>\uff1a\u4f7f\u7528twine\u5de5\u5177\u5c06\u6253\u5305\u597d\u7684\u6587\u4ef6\u4e0a\u4f20\u5230PyPI\u3002\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86twine\uff0c\u5e76\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">twine upload dist\/*<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6d4b\u8bd5\u5b89\u88c5<\/strong>\uff1a\u5728\u53d1\u5e03\u540e\uff0c\u4f7f\u7528pip\u5b89\u88c5\u4f60\u7684\u5e93\u5e76\u6d4b\u8bd5\u5176\u529f\u80fd\uff0c\u786e\u4fdd\u4e00\u5207\u6b63\u5e38\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u53d1\u5e03\u5230PyPI\u540e\uff0c\u5176\u4ed6\u5f00\u53d1\u8005\u53ef\u4ee5\u901a\u8fc7pip install\u547d\u4ee4\u8f7b\u677e\u5b89\u88c5\u548c\u4f7f\u7528\u4f60\u7684\u5e93\uff0c\u6269\u5927\u5176\u5f71\u54cd\u529b\u548c\u7528\u6237\u7fa4\u4f53\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u6210\u529f\u5236\u4f5c\u5e76\u53d1\u5e03\u4e00\u4e2aPython\u5e93\u3002\u786e\u4fdd\u5728\u6574\u4e2a\u8fc7\u7a0b\u4e2d\u5173\u6ce8\u4ee3\u7801\u8d28\u91cf\u3001\u6587\u6863\u7f16\u5199\u548c\u7528\u6237\u4f53\u9a8c\uff0c\u4ee5\u63d0\u9ad8\u5e93\u7684\u53ef\u7528\u6027\u548c\u53d7\u6b22\u8fce\u7a0b\u5ea6\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5236\u4f5cPython\u5e93\u9700\u8981\u54ea\u4e9b\u57fa\u672c\u6b65\u9aa4\uff1f<\/strong><br \/>\u5236\u4f5cPython\u5e93\u7684\u57fa\u672c\u6b65\u9aa4\u5305\u62ec\uff1a\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939\u6765\u5b58\u653e\u5e93\u7684\u4ee3\u7801\uff0c\u7f16\u5199\u6838\u5fc3\u529f\u80fd\u7684Python\u6587\u4ef6\uff0c\u6dfb\u52a0<code>setup.py<\/code>\u6587\u4ef6\u4ee5\u5b9a\u4e49\u5e93\u7684\u5143\u6570\u636e\u548c\u4f9d\u8d56\u6027\uff0c\u7f16\u5199\u6587\u6863\u548c\u793a\u4f8b\u4ee3\u7801\uff0c\u6700\u540e\u53ef\u4ee5\u9009\u62e9\u5c06\u5176\u53d1\u5e03\u5230PyPI\uff08Python Package Index\uff09\u3002\u786e\u4fdd\u4ee3\u7801\u7ed3\u6784\u6e05\u6670\uff0c\u91c7\u7528\u9002\u5f53\u7684\u547d\u540d\u7ea6\u5b9a\uff0c\u65b9\u4fbf\u5176\u4ed6\u5f00\u53d1\u8005\u7406\u89e3\u548c\u4f7f\u7528\u3002<\/p>\n<p><strong>\u5728\u521b\u5efaPython\u5e93\u65f6\uff0c\u5982\u4f55\u7ba1\u7406\u4f9d\u8d56\u5173\u7cfb\uff1f<\/strong><br \/>\u5728\u521b\u5efaPython\u5e93\u65f6\uff0c\u7ba1\u7406\u4f9d\u8d56\u5173\u7cfb\u662f\u5173\u952e\u3002\u53ef\u4ee5\u5728<code>setup.py<\/code>\u6587\u4ef6\u4e2d\u4f7f\u7528<code>install_requires<\/code>\u53c2\u6570\u6765\u5217\u51fa\u6240\u6709\u9700\u8981\u7684\u4f9d\u8d56\u5305\u3002\u6b64\u5916\uff0c\u4f7f\u7528<code>requirements.txt<\/code>\u6587\u4ef6\u8bb0\u5f55\u9879\u76ee\u7684\u4f9d\u8d56\u53ca\u5176\u7248\u672c\uff0c\u4ee5\u4fbf\u5176\u4ed6\u5f00\u53d1\u8005\u5728\u5b89\u88c5\u5e93\u65f6\u80fd\u591f\u987a\u5229\u8bbe\u7f6e\u73af\u5883\u3002\u786e\u4fdd\u5b9a\u671f\u66f4\u65b0\u8fd9\u4e9b\u4f9d\u8d56\uff0c\u4fdd\u6301\u5e93\u7684\u517c\u5bb9\u6027\u548c\u5b89\u5168\u6027\u3002<\/p>\n<p><strong>\u5982\u4f55\u5bf9\u6211\u7684Python\u5e93\u8fdb\u884c\u6d4b\u8bd5\u548c\u8c03\u8bd5\uff1f<\/strong><br \/>\u5bf9Python\u5e93\u8fdb\u884c\u6d4b\u8bd5\u548c\u8c03\u8bd5\u662f\u786e\u4fdd\u4ee3\u7801\u8d28\u91cf\u7684\u91cd\u8981\u73af\u8282\u3002\u53ef\u4ee5\u4f7f\u7528<code>unittest<\/code>\u3001<code>pytest<\/code>\u6216<code>doctest<\/code>\u7b49\u6d4b\u8bd5\u6846\u67b6\u6765\u7f16\u5199\u5355\u5143\u6d4b\u8bd5\u548c\u96c6\u6210\u6d4b\u8bd5\u3002\u8fd0\u884c\u6d4b\u8bd5\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u6216\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u6765\u67e5\u770b\u7ed3\u679c\u3002\u8c03\u8bd5\u65f6\u53ef\u4ee5\u4f7f\u7528Python\u7684\u5185\u7f6e\u8c03\u8bd5\u5668<code>pdb<\/code>\uff0c\u6216\u5229\u7528IDE\u63d0\u4f9b\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u5e2e\u52a9\u53d1\u73b0\u548c\u4fee\u590d\u4ee3\u7801\u4e2d\u7684\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5236\u4f5cPython\u5e93\uff0c\u4f60\u9700\u8981\uff1a\u660e\u786e\u5e93\u7684\u529f\u80fd\u3001\u7f16\u5199\u6a21\u5757\u4ee3\u7801\u3001\u521b\u5efasetup.py\u6587\u4ef6\u3001\u7f16\u5199\u6587\u6863\u3001\u53d1\u5e03\u5230PyPI\u3002 [&hellip;]","protected":false},"author":3,"featured_media":941101,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/941097"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=941097"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/941097\/revisions"}],"predecessor-version":[{"id":941102,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/941097\/revisions\/941102"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/941101"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=941097"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=941097"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=941097"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}