{"id":1102597,"date":"2025-01-08T16:01:39","date_gmt":"2025-01-08T08:01:39","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1102597.html"},"modified":"2025-01-08T16:01:41","modified_gmt":"2025-01-08T08:01:41","slug":"%e7%ac%ac%e4%b8%89%e6%96%b9%e5%8c%85-python-%e5%a6%82%e4%bd%95%e5%88%b6%e4%bd%9c-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1102597.html","title":{"rendered":"\u7b2c\u4e09\u65b9\u5305 python \u5982\u4f55\u5236\u4f5c"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25064821\/29b00da2-e5c2-44f3-8562-b79601ba77f3.webp\" alt=\"\u7b2c\u4e09\u65b9\u5305 python \u5982\u4f55\u5236\u4f5c\" \/><\/p>\n<p><p> <strong>\u7b2c\u4e09\u65b9\u5305python\u5982\u4f55\u5236\u4f5c\uff1a\u4e86\u89e3\u9879\u76ee\u9700\u6c42\u3001\u7f16\u5199\u4ee3\u7801\u3001\u7f16\u5199setup.py\u3001\u7f16\u5199README\u3001\u6d4b\u8bd5\u5305\u3001\u53d1\u5e03\u5305\u3001\u7ef4\u62a4\u5305<\/strong>\u3002\u5176\u4e2d\uff0c\u7f16\u5199\u4ee3\u7801\u662f\u5236\u4f5c\u7b2c\u4e09\u65b9\u5305\u7684\u6838\u5fc3\u6b65\u9aa4\u3002\u7f16\u5199\u4ee3\u7801\u9700\u8981\u6e05\u6670\u7684\u7ed3\u6784\u548c\u826f\u597d\u7684\u6ce8\u91ca\uff0c\u8fd9\u6837\u4e0d\u4ec5\u6709\u52a9\u4e8e\u81ea\u5df1\u7ef4\u62a4\uff0c\u4e5f\u65b9\u4fbf\u5176\u4ed6\u5f00\u53d1\u8005\u4f7f\u7528\u548c\u7406\u89e3\u3002\u540c\u65f6\uff0c\u7f16\u5199\u4ee3\u7801\u65f6\u9700\u8981\u6ce8\u610f\u6a21\u5757\u5316\u8bbe\u8ba1\uff0c\u786e\u4fdd\u4ee3\u7801\u7684\u53ef\u590d\u7528\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4e86\u89e3\u9879\u76ee\u9700\u6c42<\/h3>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u5236\u4f5c\u7b2c\u4e09\u65b9\u5305\u4e4b\u524d\uff0c\u9996\u5148\u8981\u660e\u786e\u9879\u76ee\u7684\u9700\u6c42\u3002\u4e86\u89e3\u9879\u76ee\u9700\u6c42\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u529f\u80fd\u9700\u6c42<\/strong>\uff1a\u786e\u5b9a\u5305\u9700\u8981\u5b9e\u73b0\u54ea\u4e9b\u529f\u80fd\uff0c\u8fd9\u4e9b\u529f\u80fd\u5e94\u8be5\u662f\u6e05\u6670\u3001\u5177\u4f53\u548c\u53ef\u5b9e\u73b0\u7684\u3002\u53ef\u4ee5\u901a\u8fc7\u4e0e\u56e2\u961f\u6c9f\u901a\u6216\u8005\u7528\u6237\u53cd\u9988\u6765\u786e\u5b9a\u529f\u80fd\u9700\u6c42\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u76ee\u6807\u7528\u6237<\/strong>\uff1a\u786e\u5b9a\u5305\u7684\u76ee\u6807\u7528\u6237\u7fa4\u4f53\uff0c\u4ed6\u4eec\u7684\u6280\u672f\u6c34\u5e73\u3001\u4f7f\u7528\u73af\u5883\u4ee5\u53ca\u4ed6\u4eec\u6700\u5173\u5fc3\u7684\u529f\u80fd\u70b9\u662f\u4ec0\u4e48\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u517c\u5bb9\u6027\u8981\u6c42<\/strong>\uff1a\u8003\u8651\u5305\u9700\u8981\u517c\u5bb9\u54ea\u4e9bPython\u7248\u672c\u4ee5\u53ca\u5176\u4ed6\u4f9d\u8d56\u9879\u7684\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e86\u89e3\u9879\u76ee\u9700\u6c42\u6709\u52a9\u4e8e\u786e\u5b9a\u5305\u7684\u8bbe\u8ba1\u65b9\u5411\u548c\u6280\u672f\u9009\u578b\uff0c\u4e3a\u540e\u7eed\u7684\u5f00\u53d1\u5de5\u4f5c\u6253\u4e0b\u575a\u5b9e\u57fa\u7840\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u7f16\u5199\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u7f16\u5199\u4ee3\u7801\u662f\u5236\u4f5c\u7b2c\u4e09\u65b9\u5305\u7684\u6838\u5fc3\u6b65\u9aa4\u3002\u5728\u7f16\u5199\u4ee3\u7801\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6a21\u5757\u5316\u8bbe\u8ba1<\/strong>\uff1a\u5c06\u4ee3\u7801\u5206\u6210\u591a\u4e2a\u6a21\u5757\uff0c\u6bcf\u4e2a\u6a21\u5757\u5b9e\u73b0\u72ec\u7acb\u7684\u529f\u80fd\u3002\u8fd9\u6709\u52a9\u4e8e\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u590d\u7528\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u826f\u597d\u7684\u6ce8\u91ca\u548c\u6587\u6863<\/strong>\uff1a\u5728\u4ee3\u7801\u4e2d\u6dfb\u52a0\u8be6\u7ec6\u7684\u6ce8\u91ca\uff0c\u5e76\u7f16\u5199\u6587\u6863\uff0c\u8bf4\u660e\u6bcf\u4e2a\u6a21\u5757\u7684\u529f\u80fd\u3001\u4f7f\u7528\u65b9\u6cd5\u548c\u6ce8\u610f\u4e8b\u9879\u3002\u826f\u597d\u7684\u6ce8\u91ca\u548c\u6587\u6863\u4e0d\u4ec5\u6709\u52a9\u4e8e\u81ea\u5df1\u7ef4\u62a4\u4ee3\u7801\uff0c\u4e5f\u65b9\u4fbf\u5176\u4ed6\u5f00\u53d1\u8005\u4f7f\u7528\u548c\u7406\u89e3\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4ee3\u7801\u98ce\u683c<\/strong>\uff1a\u9075\u5faaPEP 8\u7b49Python\u4ee3\u7801\u98ce\u683c\u6307\u5357\uff0c\u4fdd\u6301\u4ee3\u7801\u7684\u4e00\u81f4\u6027\u548c\u53ef\u8bfb\u6027\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5355\u5143\u6d4b\u8bd5<\/strong>\uff1a\u7f16\u5199\u5355\u5143\u6d4b\u8bd5\uff0c\u786e\u4fdd\u6bcf\u4e2a\u529f\u80fd\u6a21\u5757\u90fd\u80fd\u6b63\u5e38\u5de5\u4f5c\u3002\u53ef\u4ee5\u4f7f\u7528unittest\u3001pytest\u7b49\u6d4b\u8bd5\u6846\u67b6\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\"># example_module.py<\/p>\n<p>def example_function(param1, param2):<\/p>\n<p>    &quot;&quot;&quot;<\/p>\n<p>    \u793a\u4f8b\u51fd\u6570\uff0c\u6267\u884c\u793a\u4f8b\u64cd\u4f5c\u3002<\/p>\n<p>    \u53c2\u6570:<\/p>\n<p>    param1 (int): \u7b2c\u4e00\u4e2a\u53c2\u6570\u3002<\/p>\n<p>    param2 (int): \u7b2c\u4e8c\u4e2a\u53c2\u6570\u3002<\/p>\n<p>    \u8fd4\u56de:<\/p>\n<p>    int: \u4e24\u4e2a\u53c2\u6570\u7684\u548c\u3002<\/p>\n<p>    &quot;&quot;&quot;<\/p>\n<p>    return param1 + param2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u7f16\u5199setup.py<\/h3>\n<\/p>\n<p><p>setup.py\u6587\u4ef6\u662f\u5236\u4f5c\u7b2c\u4e09\u65b9\u5305\u7684\u5173\u952e\u6587\u4ef6\uff0c\u5b83\u5305\u542b\u4e86\u5305\u7684\u5143\u6570\u636e\u548c\u5b89\u88c5\u4fe1\u606f\u3002\u4e00\u4e2a\u7b80\u5355\u7684setup.py\u6587\u4ef6\u53ef\u80fd\u5982\u4e0b\u6240\u793a\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;example_package&#39;,<\/p>\n<p>    version=&#39;0.1.0&#39;,<\/p>\n<p>    description=&#39;A simple example package&#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>    url=&#39;https:\/\/github.com\/yourusername\/example_package&#39;,<\/p>\n<p>    packages=find_packages(),<\/p>\n<p>    install_requires=[<\/p>\n<p>        &#39;required_package1&#39;,<\/p>\n<p>        &#39;required_package2&#39;,<\/p>\n<p>    ],<\/p>\n<p>    classifiers=[<\/p>\n<p>        &#39;Programming Language :: Python :: 3&#39;,<\/p>\n<p>        &#39;License :: OSI Approved :: MIT License&#39;,<\/p>\n<p>        &#39;Operating System :: OS Independent&#39;,<\/p>\n<p>    ],<\/p>\n<p>    python_requires=&#39;&gt;=3.6&#39;,<\/p>\n<p>)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u7f16\u5199README<\/h3>\n<\/p>\n<p><p>README\u6587\u4ef6\u662f\u9879\u76ee\u7684\u8bf4\u660e\u6587\u6863\uff0c\u901a\u5e38\u4f7f\u7528Markdown\u683c\u5f0f\u7f16\u5199\u3002README\u6587\u4ef6\u5e94\u8be5\u5305\u542b\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9879\u76ee\u7b80\u4ecb<\/strong>\uff1a\u7b80\u8981\u4ecb\u7ecd\u9879\u76ee\u7684\u529f\u80fd\u548c\u7279\u70b9\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u65b9\u6cd5<\/strong>\uff1a\u8bf4\u660e\u5982\u4f55\u5b89\u88c5\u548c\u914d\u7f6e\u5305\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u793a\u4f8b<\/strong>\uff1a\u63d0\u4f9b\u4e00\u4e9b\u4ee3\u7801\u793a\u4f8b\uff0c\u5c55\u793a\u5305\u7684\u57fa\u672c\u7528\u6cd5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8d21\u732e\u6307\u5357<\/strong>\uff1a\u8bf4\u660e\u5982\u4f55\u8d21\u732e\u4ee3\u7801\u3001\u63d0\u4ea4\u95ee\u9898\u548c\u53c2\u4e0e\u9879\u76ee\u7684\u5f00\u53d1\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><pre><code class=\"language-markdown\"># Example Package<\/p>\n<p>This is a simple example package.<\/p>\n<p>## Installation<\/p>\n<p>```bash<\/p>\n<p>pip install example_package<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>Usage<\/h2>\n<\/p>\n<p><pre><code class=\"language-python\">from example_package import example_function<\/p>\n<p>result = example_function(1, 2)<\/p>\n<p>print(result)  # \u8f93\u51fa: 3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>Contributing<\/h2>\n<\/p>\n<p><p>If you want to contribute to this project, please read the <a href=\"CONTRIBUTING.md\">contributing guidelines<\/a>.<\/p>\n<\/p>\n<p><pre><code><\/p>\n<p>### \u4e94\u3001\u6d4b\u8bd5\u5305<\/p>\n<p>\u5728\u53d1\u5e03\u5305\u4e4b\u524d\uff0c\u9700\u8981\u5bf9\u5305\u8fdb\u884c\u5168\u9762\u7684\u6d4b\u8bd5\uff0c\u786e\u4fdd\u5176\u5728\u4e0d\u540c\u73af\u5883\u4e0b\u90fd\u80fd\u6b63\u5e38\u5de5\u4f5c\u3002\u6d4b\u8bd5\u5305\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a<\/p>\n<p>1. &lt;strong&gt;\u5355\u5143\u6d4b\u8bd5&lt;\/strong&gt;\uff1a\u4f7f\u7528\u6d4b\u8bd5\u6846\u67b6\u5bf9\u6bcf\u4e2a\u529f\u80fd\u6a21\u5757\u8fdb\u884c\u5355\u5143\u6d4b\u8bd5\uff0c\u786e\u4fdd\u5176\u529f\u80fd\u6b63\u786e\u3002<\/p>\n<p>2. &lt;strong&gt;\u96c6\u6210\u6d4b\u8bd5&lt;\/strong&gt;\uff1a\u5bf9\u6574\u4e2a\u5305\u8fdb\u884c\u96c6\u6210\u6d4b\u8bd5\uff0c\u786e\u4fdd\u5404\u4e2a\u6a21\u5757\u4e4b\u95f4\u80fd\u591f\u6b63\u786e\u534f\u4f5c\u3002<\/p>\n<p>3. &lt;strong&gt;\u517c\u5bb9\u6027\u6d4b\u8bd5&lt;\/strong&gt;\uff1a\u5728\u4e0d\u540c\u7684Python\u7248\u672c\u548c\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u6d4b\u8bd5\u5305\uff0c\u786e\u4fdd\u5176\u517c\u5bb9\u6027\u3002<\/p>\n<p>4. &lt;strong&gt;\u7528\u6237\u6d4b\u8bd5&lt;\/strong&gt;\uff1a\u9080\u8bf7\u4e00\u4e9b\u76ee\u6807\u7528\u6237\u5bf9\u5305\u8fdb\u884c\u6d4b\u8bd5\uff0c\u6536\u96c6\u53cd\u9988\u610f\u89c1\uff0c\u6539\u8fdb\u5305\u7684\u529f\u80fd\u548c\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n<p>### \u516d\u3001\u53d1\u5e03\u5305<\/p>\n<p>\u5728\u5305\u7ecf\u8fc7\u5168\u9762\u6d4b\u8bd5\u5e76\u786e\u8ba4\u6ca1\u6709\u95ee\u9898\u540e\uff0c\u53ef\u4ee5\u5c06\u5305\u53d1\u5e03\u5230Python Package Index (PyPI)\u3002\u53d1\u5e03\u5305\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<p>1. &lt;strong&gt;\u751f\u6210\u5206\u53d1\u6587\u4ef6&lt;\/strong&gt;\uff1a\u4f7f\u7528`setup.py`\u751f\u6210\u6e90\u5206\u53d1\u6587\u4ef6\u548c\u8f6e\u5b50\u5206\u53d1\u6587\u4ef6\u3002<\/p>\n<p>```bash<\/p>\n<p>python setup.py sdist bdist_wheel<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u4e0a\u4f20\u5230PyPI<\/strong>\uff1a\u4f7f\u7528twine\u5de5\u5177\u5c06\u5206\u53d1\u6587\u4ef6\u4e0a\u4f20\u5230PyPI\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">twine upload dist\/*<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e03\u3001\u7ef4\u62a4\u5305<\/h3>\n<\/p>\n<p><p>\u53d1\u5e03\u5305\u540e\uff0c\u8fd8\u9700\u8981\u5bf9\u5305\u8fdb\u884c\u7ef4\u62a4\uff0c\u53ca\u65f6\u4fee\u590dbug\u3001\u6dfb\u52a0\u65b0\u529f\u80fd\u548c\u66f4\u65b0\u6587\u6863\u3002\u7ef4\u62a4\u5305\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5904\u7406\u7528\u6237\u53cd\u9988<\/strong>\uff1a\u53ca\u65f6\u56de\u590d\u7528\u6237\u7684\u53cd\u9988\u610f\u89c1\uff0c\u89e3\u51b3\u4ed6\u4eec\u9047\u5230\u7684\u95ee\u9898\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4fee\u590dbug<\/strong>\uff1a\u53d1\u73b0bug\u540e\uff0c\u5c3d\u5feb\u4fee\u590d\u5e76\u53d1\u5e03\u65b0\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6dfb\u52a0\u65b0\u529f\u80fd<\/strong>\uff1a\u6839\u636e\u7528\u6237\u9700\u6c42\u548c\u6280\u672f\u53d1\u5c55\uff0c\u5b9a\u671f\u6dfb\u52a0\u65b0\u529f\u80fd\uff0c\u4e0d\u65ad\u5b8c\u5584\u5305\u7684\u529f\u80fd\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u66f4\u65b0\u6587\u6863<\/strong>\uff1a\u4fdd\u6301\u6587\u6863\u7684\u6700\u65b0\u72b6\u6001\uff0c\u786e\u4fdd\u5176\u4e0e\u4ee3\u7801\u4e00\u81f4\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7248\u672c\u7ba1\u7406<\/strong>\uff1a\u4f7f\u7528\u7248\u672c\u63a7\u5236\u5de5\u5177\uff08\u5982Git\uff09\u7ba1\u7406\u4ee3\u7801\uff0c\u5408\u7406\u5b89\u6392\u7248\u672c\u53d1\u5e03\u5468\u671f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u5c31\u53ef\u4ee5\u5236\u4f5c\u51fa\u4e00\u4e2a\u9ad8\u8d28\u91cf\u7684\u7b2c\u4e09\u65b9\u5305\uff0c\u5e76\u53d1\u5e03\u5230PyPI\u4f9b\u5176\u4ed6\u5f00\u53d1\u8005\u4f7f\u7528\u3002\u5236\u4f5c\u7b2c\u4e09\u65b9\u5305\u4e0d\u4ec5\u53ef\u4ee5\u63d0\u9ad8\u81ea\u5df1\u7684\u6280\u672f\u6c34\u5e73\uff0c\u8fd8\u53ef\u4ee5\u4e3a\u5f00\u6e90\u793e\u533a\u505a\u51fa\u8d21\u732e\u3002\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u80fd\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u6765\u5236\u4f5cPython\u7b2c\u4e09\u65b9\u5305\uff1f<\/strong><br \/>\u5236\u4f5cPython\u7b2c\u4e09\u65b9\u5305\u65f6\uff0c\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u662f\u81f3\u5173\u91cd\u8981\u7684\u3002\u5e38\u7528\u7684\u5de5\u5177\u5305\u62ecsetuptools\u548cdistutils\uff0c\u5b83\u4eec\u53ef\u4ee5\u5e2e\u52a9\u4f60\u8f7b\u677e\u5730\u6253\u5305\u548c\u5206\u53d1\u4ee3\u7801\u3002setuptools\u63d0\u4f9b\u4e86\u66f4\u591a\u529f\u80fd\uff0c\u4f8b\u5982\u4f9d\u8d56\u7ba1\u7406\u548c\u81ea\u52a8\u5316\u6784\u5efa\u3002\u786e\u4fdd\u5b89\u88c5\u4e86\u6700\u65b0\u7248\u672c\u7684\u8fd9\u4e9b\u5de5\u5177\uff0c\u4ee5\u4fbf\u83b7\u5f97\u66f4\u597d\u7684\u652f\u6301\u548c\u529f\u80fd\u3002<\/p>\n<p><strong>\u5728\u521b\u5efaPython\u7b2c\u4e09\u65b9\u5305\u65f6\uff0c\u5982\u4f55\u7ba1\u7406\u4f9d\u8d56\u5173\u7cfb\uff1f<\/strong><br \/>\u7ba1\u7406\u4f9d\u8d56\u5173\u7cfb\u662f\u5236\u4f5cPython\u7b2c\u4e09\u65b9\u5305\u7684\u4e00\u4e2a\u91cd\u8981\u6b65\u9aa4\u3002\u53ef\u4ee5\u5728<code>setup.py<\/code>\u6587\u4ef6\u4e2d\u4f7f\u7528<code>install_requires<\/code>\u53c2\u6570\u6765\u6307\u5b9a\u6240\u9700\u7684\u4f9d\u8d56\u5305\u3002\u540c\u65f6\uff0c\u4f7f\u7528<code>requirements.txt<\/code>\u6587\u4ef6\u5217\u51fa\u9879\u76ee\u7684\u6240\u6709\u4f9d\u8d56\uff0c\u5e76\u901a\u8fc7<code>pip install -r requirements.txt<\/code>\u547d\u4ee4\u6765\u5b89\u88c5\u8fd9\u4e9b\u4f9d\u8d56\u3002\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u7528\u6237\u5728\u5b89\u88c5\u4f60\u7684\u5305\u65f6\uff0c\u80fd\u591f\u540c\u65f6\u5b89\u88c5\u6240\u9700\u7684\u6240\u6709\u4f9d\u8d56\u3002<\/p>\n<p><strong>\u5982\u4f55\u6d4b\u8bd5\u6211\u7684Python\u7b2c\u4e09\u65b9\u5305\u4ee5\u786e\u4fdd\u5176\u6b63\u5e38\u5de5\u4f5c\uff1f<\/strong><br \/>\u5728\u53d1\u5e03Python\u7b2c\u4e09\u65b9\u5305\u4e4b\u524d\uff0c\u8fdb\u884c\u5145\u5206\u7684\u6d4b\u8bd5\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u53ef\u4ee5\u4f7f\u7528unittest\u3001pytest\u6216doctest\u7b49\u6d4b\u8bd5\u6846\u67b6\u6765\u7f16\u5199\u548c\u8fd0\u884c\u6d4b\u8bd5\u7528\u4f8b\u3002\u786e\u4fdd\u8986\u76d6\u5305\u4e2d\u7684\u4e3b\u8981\u529f\u80fd\u548c\u8fb9\u754c\u60c5\u51b5\u3002\u53ef\u4ee5\u5728\u672c\u5730\u73af\u5883\u4e2d\u8fdb\u884c\u5355\u5143\u6d4b\u8bd5\uff0c\u5e76\u4f7f\u7528\u6301\u7eed\u96c6\u6210\u5de5\u5177\uff08\u5982GitHub Actions\u6216Travis CI\uff09\u81ea\u52a8\u5316\u6d4b\u8bd5\u8fc7\u7a0b\uff0c\u4ee5\u4fbf\u5728\u6bcf\u6b21\u66f4\u65b0\u65f6\u53ca\u65f6\u53d1\u73b0\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u7b2c\u4e09\u65b9\u5305python\u5982\u4f55\u5236\u4f5c\uff1a\u4e86\u89e3\u9879\u76ee\u9700\u6c42\u3001\u7f16\u5199\u4ee3\u7801\u3001\u7f16\u5199setup.py\u3001\u7f16\u5199README\u3001\u6d4b\u8bd5\u5305\u3001\u53d1\u5e03\u5305\u3001 [&hellip;]","protected":false},"author":3,"featured_media":1102602,"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\/1102597"}],"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=1102597"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1102597\/revisions"}],"predecessor-version":[{"id":1102604,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1102597\/revisions\/1102604"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1102602"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1102597"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1102597"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1102597"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}