{"id":1160642,"date":"2025-01-13T19:07:11","date_gmt":"2025-01-13T11:07:11","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1160642.html"},"modified":"2025-01-13T19:07:14","modified_gmt":"2025-01-13T11:07:14","slug":"python%e5%86%99%e5%85%a5%e7%a8%8b%e5%ba%8f%e5%90%8e%e5%a6%82%e4%bd%95%e8%bf%90%e8%a1%8c","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1160642.html","title":{"rendered":"python\u5199\u5165\u7a0b\u5e8f\u540e\u5982\u4f55\u8fd0\u884c"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25202057\/3e9758f4-7983-4c54-9231-1a3421d02464.webp\" alt=\"python\u5199\u5165\u7a0b\u5e8f\u540e\u5982\u4f55\u8fd0\u884c\" \/><\/p>\n<p><p> <strong>\u8981\u8fd0\u884cPython\u5199\u5165\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u547d\u4ee4\u884c\u3001\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3001\u811a\u672c\u6587\u4ef6\u7b49\u591a\u79cd\u65b9\u5f0f\u8fdb\u884c\u3002\u5177\u4f53\u6b65\u9aa4\u5305\u62ec\uff1a\u5b89\u88c5Python\u73af\u5883\u3001\u7f16\u5199Python\u811a\u672c\u3001\u901a\u8fc7\u547d\u4ee4\u884c\u6216IDE\u8fd0\u884c\u811a\u672c\u3002<\/strong> \u5728\u8fd9\u5176\u4e2d\uff0c<strong>\u901a\u8fc7\u547d\u4ee4\u884c\u8fd0\u884cPython\u811a\u672c<\/strong>\u662f\u6700\u5e38\u89c1\u4e14\u4fbf\u6377\u7684\u4e00\u79cd\u65b9\u5f0f\u3002<\/p>\n<\/p>\n<p><p>\u8fd0\u884cPython\u5199\u5165\u7a0b\u5e8f\u7684\u8be6\u7ec6\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5b89\u88c5Python\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u5728\u8fd0\u884c\u4efb\u4f55Python\u7a0b\u5e8f\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u786e\u4fdd\u7cfb\u7edf\u4e2d\u5df2\u5b89\u88c5\u4e86Python\u89e3\u91ca\u5668\u3002Python\u7684\u5b89\u88c5\u53ef\u4ee5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%E4%B8%8B%E8%BD%BD%E5%B9%B6%E5%AE%89%E8%A3%85%E5%AF%B9%E5%BA%94%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E7%9A%84%E7%89%88%E6%9C%AC%E3%80%82%E5%AE%89%E8%A3%85%E5%AE%8C%E6%88%90%E5%90%8E%EF%BC%8C%E5%8F%AF%E4%BB%A5%E5%9C%A8%E5%91%BD%E4%BB%A4%E8%A1%8C%E4%B8%AD%E9%80%9A%E8%BF%87%E4%BB%A5%E4%B8%8B%E5%91%BD%E4%BB%A4%E6%9D%A5%E9%AA%8C%E8%AF%81%E5%AE%89%E8%A3%85%E6%98%AF%E5%90%A6%E6%88%90%E5%8A%9F%EF%BC%9A\">https:\/\/www.python.org\/\uff09\u4e0b\u8f7d\u5e76\u5b89\u88c5\u5bf9\u5e94\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\uff1a<\/a><\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u6210\u529f\u5b89\u88c5\uff0c\u4f1a\u663e\u793aPython\u7684\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u7f16\u5199Python\u811a\u672c<\/h3>\n<\/p>\n<p><p>Python\u811a\u672c\u901a\u5e38\u4ee5\u201c.py\u201d\u4f5c\u4e3a\u6587\u4ef6\u6269\u5c55\u540d\u3002\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u6587\u672c\u7f16\u8f91\u5668\uff08\u4f8b\u5982\uff0cNotepad++\u3001Sublime Text\u3001VSCode\u7b49\uff09\u7f16\u5199Python\u4ee3\u7801\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cexample.py\u201d\u7684\u6587\u4ef6\u5e76\u5199\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># example.py<\/p>\n<p>def m<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>n():<\/p>\n<p>    with open(&#39;output.txt&#39;, &#39;w&#39;) as file:<\/p>\n<p>        file.write(&#39;Hello, World!&#39;)<\/p>\n<p>if __name__ == &#39;__main__&#39;:<\/p>\n<p>    main()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6bb5\u4ee3\u7801\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201coutput.txt\u201d\u7684\u6587\u4ef6\uff0c\u5e76\u5199\u5165\u201cHello, World!\u201d\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u901a\u8fc7\u547d\u4ee4\u884c\u8fd0\u884cPython\u811a\u672c<\/h3>\n<\/p>\n<p><p>\u5728\u547d\u4ee4\u884c\u4e2d\u5bfc\u822a\u5230\u5305\u542bPython\u811a\u672c\u7684\u76ee\u5f55\uff0c\u7136\u540e\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python example.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u6267\u884c\u811a\u672c\uff0c\u5e76\u5728\u5f53\u524d\u76ee\u5f55\u4e2d\u751f\u6210\u4e00\u4e2a\u5305\u542b\u201cHello, World!\u201d\u7684\u201coutput.txt\u201d\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09<\/h3>\n<\/p>\n<p><p>IDE\u901a\u5e38\u63d0\u4f9b\u66f4\u52a0\u4e30\u5bcc\u7684\u8c03\u8bd5\u548c\u8fd0\u884c\u529f\u80fd\u3002\u5e38\u7528\u7684Python IDE\u5305\u62ecPyCharm\u3001VSCode\u548cJupyter Notebook\u7b49\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528PyCharm\u8fd0\u884cPython\u811a\u672c\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5b89\u88c5\u5e76\u6253\u5f00PyCharm\u3002<\/li>\n<li>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u9879\u76ee\u6216\u6253\u5f00\u4e00\u4e2a\u73b0\u6709\u9879\u76ee\u3002<\/li>\n<li>\u5728\u9879\u76ee\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python\u6587\u4ef6\uff08\u4f8b\u5982\u201cexample.py\u201d\uff09\uff0c\u5e76\u5199\u5165Python\u4ee3\u7801\u3002<\/li>\n<li>\u53f3\u952e\u70b9\u51fb\u6587\u4ef6\uff0c\u7136\u540e\u9009\u62e9\u201cRun &#39;example&#39;\u201d\u3002<\/li>\n<li>\u89c2\u5bdf\u8f93\u51fa\u7ed3\u679c\u3002<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u8fd0\u884cPython\u7a0b\u5e8f\u7684\u4e0d\u540c\u65b9\u5f0f<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u4e0a\u8ff0\u6700\u5e38\u89c1\u7684\u65b9\u5f0f\u5916\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8fd0\u884cPython\u7a0b\u5e8f\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u901a\u8fc7\u547d\u4ee4\u884c\u8fd0\u884c<\/h4>\n<\/p>\n<p><p>\u5982\u524d\u6240\u8ff0\uff0c\u547d\u4ee4\u884c\u8fd0\u884c\u662f\u6700\u57fa\u7840\u4e14\u5e38\u7528\u7684\u65b9\u5f0f\u3002\u53ea\u9700\u5bfc\u822a\u5230\u811a\u672c\u6240\u5728\u76ee\u5f55\u5e76\u6267\u884c\u201cpython script_name.py\u201d\u547d\u4ee4\u5373\u53ef\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u901a\u8fc7IDE\u8fd0\u884c<\/h4>\n<\/p>\n<p><p>IDE\u63d0\u4f9b\u4e86\u66f4\u4fbf\u6377\u7684\u65b9\u5f0f\u6765\u8fd0\u884c\u548c\u8c03\u8bd5Python\u7a0b\u5e8f\u3002\u9664\u4e86PyCharm\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528VSCode\u3001Jupyter Notebook\u7b49\u6765\u8fd0\u884cPython\u7a0b\u5e8f\u3002VSCode\u548cJupyter Notebook\u5177\u6709\u4e30\u5bcc\u7684\u63d2\u4ef6\u548c\u6269\u5c55\u529f\u80fd\uff0c\u53ef\u4ee5\u63d0\u4f9b\u66f4\u597d\u7684\u5f00\u53d1\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u901a\u8fc7\u4efb\u52a1\u8ba1\u5212\u7a0b\u5e8f\u6216cron\u5b9a\u65f6\u4efb\u52a1\u8fd0\u884c<\/h4>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4efb\u52a1\u8ba1\u5212\u7a0b\u5e8f\u6765\u5b9a\u65f6\u8fd0\u884cPython\u811a\u672c\u3002\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528cron\u5b9a\u65f6\u4efb\u52a1\u6765\u5b9e\u73b0\u76f8\u540c\u7684\u529f\u80fd\u3002\u8fd9\u5728\u81ea\u52a8\u5316\u4efb\u52a1\u4e2d\u975e\u5e38\u6709\u7528\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u901a\u8fc7Web\u670d\u52a1\u5668\u8fd0\u884c<\/h4>\n<\/p>\n<p><p>\u5728Web\u5f00\u53d1\u4e2d\uff0cPython\u811a\u672c\u901a\u5e38\u4f5c\u4e3a\u670d\u52a1\u5668\u7aef\u4ee3\u7801\u8fd0\u884c\u3002\u5e38\u89c1\u7684\u6846\u67b6\u5305\u62ecFlask\u3001Django\u7b49\u3002\u901a\u8fc7\u8bbe\u7f6eWeb\u670d\u52a1\u5668\uff0c\u53ef\u4ee5\u5728\u5ba2\u6237\u7aef\u8bf7\u6c42\u65f6\u8fd0\u884cPython\u811a\u672c\u3002<\/p>\n<\/p>\n<p><h4>5\u3001\u901a\u8fc7\u5bb9\u5668\u5316\u6280\u672f\u8fd0\u884c<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528Docker\u7b49\u5bb9\u5668\u5316\u6280\u672f\uff0c\u53ef\u4ee5\u5c06Python\u811a\u672c\u6253\u5305\u6210\u5bb9\u5668\u955c\u50cf\uff0c\u5e76\u5728\u4efb\u4f55\u652f\u6301Docker\u7684\u73af\u5883\u4e2d\u8fd0\u884c\u3002\u8fd9\u79cd\u65b9\u5f0f\u5177\u6709\u826f\u597d\u7684\u53ef\u79fb\u690d\u6027\u548c\u9694\u79bb\u6027\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001Python\u811a\u672c\u7684\u5e38\u89c1\u7528\u6cd5<\/h3>\n<\/p>\n<p><p>Python\u811a\u672c\u5177\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\u573a\u666f\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u7528\u6cd5\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u6570\u636e\u5904\u7406\u548c\u5206\u6790<\/h4>\n<\/p>\n<p><p>Python\u811a\u672c\u5e7f\u6cdb\u7528\u4e8e\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u9886\u57df\u3002\u901a\u8fc7\u4f7f\u7528Pandas\u3001NumPy\u7b49\u5e93\uff0c\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u6570\u636e\u6e05\u6d17\u3001\u5904\u7406\u548c\u5206\u6790\u3002<\/p>\n<\/p>\n<p><h4>2\u3001Web\u5f00\u53d1<\/h4>\n<\/p>\n<p><p>Python\u5728Web\u5f00\u53d1\u4e2d\u4e5f\u6709\u91cd\u8981\u5e94\u7528\u3002\u901a\u8fc7\u4f7f\u7528Flask\u3001Django\u7b49Web\u6846\u67b6\uff0c\u53ef\u4ee5\u5feb\u901f\u5f00\u53d1\u548c\u90e8\u7f72Web\u5e94\u7528\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u81ea\u52a8\u5316\u4efb\u52a1<\/h4>\n<\/p>\n<p><p>Python\u811a\u672c\u5e38\u7528\u4e8e\u81ea\u52a8\u5316\u4efb\u52a1\uff0c\u4f8b\u5982\u6587\u4ef6\u5904\u7406\u3001\u7f51\u7edc\u722c\u866b\u3001\u4efb\u52a1\u8c03\u5ea6\u7b49\u3002\u901a\u8fc7\u7f16\u5199\u811a\u672c\uff0c\u53ef\u4ee5\u5b9e\u73b0\u9ad8\u6548\u7684\u81ea\u52a8\u5316\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><h4>4\u3001<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u548c<a href=\"https:\/\/docs.pingcode.com\/tag\/AI\" target=\"_blank\">\u4eba\u5de5\u667a\u80fd<\/a><\/h4>\n<\/p>\n<p><p>Python\u662f\u673a\u5668\u5b66\u4e60\u548c\u4eba\u5de5\u667a\u80fd\u9886\u57df\u7684\u4e3b\u8981\u7f16\u7a0b\u8bed\u8a00\u3002\u901a\u8fc7\u4f7f\u7528TensorFlow\u3001PyTorch\u7b49\u5e93\uff0c\u53ef\u4ee5\u5b9e\u73b0\u673a\u5668\u5b66\u4e60\u6a21\u578b\u7684\u8bad\u7ec3\u548c\u90e8\u7f72\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001Python\u811a\u672c\u7684\u8c03\u8bd5\u6280\u5de7<\/h3>\n<\/p>\n<p><p>\u8c03\u8bd5\u662f\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u8c03\u8bd5\u6280\u5de7\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528print\u8bed\u53e5<\/h4>\n<\/p>\n<p><p>\u6700\u7b80\u5355\u7684\u8c03\u8bd5\u65b9\u6cd5\u662f\u4f7f\u7528print\u8bed\u53e5\u6765\u8f93\u51fa\u53d8\u91cf\u503c\u548c\u7a0b\u5e8f\u72b6\u6001\u3002\u8fd9\u6709\u52a9\u4e8e\u4e86\u89e3\u7a0b\u5e8f\u7684\u6267\u884c\u8fc7\u7a0b\u548c\u627e\u5230\u95ee\u9898\u6240\u5728\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528logging\u6a21\u5757<\/h4>\n<\/p>\n<p><p>\u76f8\u6bd4print\u8bed\u53e5\uff0clogging\u6a21\u5757\u63d0\u4f9b\u4e86\u66f4\u7075\u6d3b\u548c\u9ad8\u7ea7\u7684\u65e5\u5fd7\u8bb0\u5f55\u529f\u80fd\u3002\u53ef\u4ee5\u8bbe\u7f6e\u4e0d\u540c\u7684\u65e5\u5fd7\u7ea7\u522b\uff0c\u5e76\u5c06\u65e5\u5fd7\u8f93\u51fa\u5230\u6587\u4ef6\u6216\u63a7\u5236\u53f0\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u4f7f\u7528\u96c6\u6210\u8c03\u8bd5\u5668<\/h4>\n<\/p>\n<p><p>IDE\u901a\u5e38\u96c6\u6210\u4e86\u8c03\u8bd5\u5668\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u65ad\u70b9\u3001\u5355\u6b65\u6267\u884c\u4ee3\u7801\u3001\u67e5\u770b\u53d8\u91cf\u503c\u7b49\u3002\u8fd9\u5bf9\u4e8e\u590d\u6742\u7a0b\u5e8f\u7684\u8c03\u8bd5\u975e\u5e38\u6709\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u4f7f\u7528\u5355\u5143\u6d4b\u8bd5<\/h4>\n<\/p>\n<p><p>\u7f16\u5199\u5355\u5143\u6d4b\u8bd5\u53ef\u4ee5\u5e2e\u52a9\u53d1\u73b0\u548c\u4fee\u590d\u4ee3\u7801\u4e2d\u7684\u9519\u8bef\u3002\u901a\u8fc7\u4f7f\u7528unittest\u3001pytest\u7b49\u6846\u67b6\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u7f16\u5199\u548c\u8fd0\u884c\u5355\u5143\u6d4b\u8bd5\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u63d0\u9ad8Python\u811a\u672c\u6027\u80fd\u7684\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u4f18\u5316Python\u811a\u672c\u7684\u6027\u80fd\u53ef\u4ee5\u63d0\u9ad8\u7a0b\u5e8f\u7684\u8fd0\u884c\u6548\u7387\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528\u9ad8\u6548\u7684\u6570\u636e\u7ed3\u6784<\/h4>\n<\/p>\n<p><p>\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u7ed3\u6784\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u7a0b\u5e8f\u7684\u6027\u80fd\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u5b57\u5178\u800c\u4e0d\u662f\u5217\u8868\u6765\u5b58\u50a8\u952e\u503c\u5bf9\uff0c\u4f7f\u7528\u96c6\u5408\u800c\u4e0d\u662f\u5217\u8868\u6765\u68c0\u67e5\u6210\u5458\u662f\u5426\u5b58\u5728\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u907f\u514d\u91cd\u590d\u8ba1\u7b97<\/h4>\n<\/p>\n<p><p>\u907f\u514d\u91cd\u590d\u8ba1\u7b97\u53ef\u4ee5\u51cf\u5c11\u7a0b\u5e8f\u7684\u6267\u884c\u65f6\u95f4\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5c06\u8ba1\u7b97\u7ed3\u679c\u7f13\u5b58\u8d77\u6765\uff0c\u907f\u514d\u5728\u5faa\u73af\u4e2d\u91cd\u590d\u8ba1\u7b97\u76f8\u540c\u7684\u503c\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u4f7f\u7528\u591a\u7ebf\u7a0b\u6216\u591a\u8fdb\u7a0b<\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8eIO\u5bc6\u96c6\u578b\u4efb\u52a1\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u7ebf\u7a0b\u6765\u63d0\u9ad8\u6027\u80fd\u3002\u5bf9\u4e8eCPU\u5bc6\u96c6\u578b\u4efb\u52a1\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u8fdb\u7a0b\u6765\u5145\u5206\u5229\u7528\u591a\u6838\u5904\u7406\u5668\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u4f7f\u7528Cython\u6216Numba<\/h4>\n<\/p>\n<p><p>Cython\u548cNumba\u662f\u4e24\u4e2a\u7528\u4e8e\u52a0\u901fPython\u4ee3\u7801\u7684\u5de5\u5177\u3002\u901a\u8fc7\u5c06\u5173\u952e\u90e8\u5206\u7684\u4ee3\u7801\u8f6c\u6362\u4e3aC\u6216\u7f16\u8bd1\u4e3a\u673a\u5668\u7801\uff0c\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u6027\u80fd\u3002<\/p>\n<\/p>\n<p><h3>\u4e5d\u3001\u5e38\u89c1\u7684Python\u5f00\u53d1\u5de5\u5177<\/h3>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684Python\u5f00\u53d1\u5de5\u5177\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u6587\u672c\u7f16\u8f91\u5668<\/h4>\n<\/p>\n<p><p>\u5e38\u7528\u7684\u6587\u672c\u7f16\u8f91\u5668\u5305\u62ecNotepad++\u3001Sublime Text\u3001Atom\u7b49\u3002\u8fd9\u4e9b\u7f16\u8f91\u5668\u63d0\u4f9b\u4e86\u8bed\u6cd5\u9ad8\u4eae\u3001\u81ea\u52a8\u8865\u5168\u7b49\u529f\u80fd\uff0c\u65b9\u4fbf\u7f16\u5199\u548c\u7f16\u8f91Python\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09<\/h4>\n<\/p>\n<p><p>\u5e38\u7528\u7684Python IDE\u5305\u62ecPyCharm\u3001VSCode\u3001Jupyter Notebook\u7b49\u3002\u8fd9\u4e9bIDE\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u5f00\u53d1\u548c\u8c03\u8bd5\u529f\u80fd\uff0c\u9002\u5408\u5927\u578b\u9879\u76ee\u5f00\u53d1\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u7248\u672c\u63a7\u5236\u5de5\u5177<\/h4>\n<\/p>\n<p><p>\u7248\u672c\u63a7\u5236\u5de5\u5177\u5982Git\u3001SVN\u7b49\u53ef\u4ee5\u5e2e\u52a9\u7ba1\u7406\u4ee3\u7801\u7248\u672c\u548c\u534f\u4f5c\u5f00\u53d1\u3002\u4f7f\u7528Git\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u4ee3\u7801\u63d0\u4ea4\u3001\u56de\u6eda\u3001\u5206\u652f\u7ba1\u7406\u7b49\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u5305\u7ba1\u7406\u5de5\u5177<\/h4>\n<\/p>\n<p><p>Python\u7684\u5305\u7ba1\u7406\u5de5\u5177\u5982pip\u3001conda\u7b49\u53ef\u4ee5\u65b9\u4fbf\u5730\u5b89\u88c5\u548c\u7ba1\u7406\u7b2c\u4e09\u65b9\u5e93\u548c\u4f9d\u8d56\u3002\u901a\u8fc7\u4f7f\u7528\u865a\u62df\u73af\u5883\uff0c\u53ef\u4ee5\u907f\u514d\u4f9d\u8d56\u51b2\u7a81\u548c\u7248\u672c\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u3001Python\u7a0b\u5e8f\u7684\u90e8\u7f72\u548c\u53d1\u5e03<\/h3>\n<\/p>\n<p><p>\u5c06\u5f00\u53d1\u597d\u7684Python\u7a0b\u5e8f\u90e8\u7f72\u548c\u53d1\u5e03\u662f\u6700\u540e\u4e00\u6b65\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u90e8\u7f72\u548c\u53d1\u5e03\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u672c\u5730\u8fd0\u884c<\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8e\u7b80\u5355\u7684\u811a\u672c\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728\u672c\u5730\u8fd0\u884c\u548c\u6d4b\u8bd5\u3002\u5982\u679c\u9700\u8981\u5b9a\u671f\u8fd0\u884c\uff0c\u53ef\u4ee5\u4f7f\u7528\u5b9a\u65f6\u4efb\u52a1\u6216\u4efb\u52a1\u8ba1\u5212\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u670d\u52a1\u5668\u90e8\u7f72<\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8eWeb\u5e94\u7528\uff0c\u53ef\u4ee5\u5c06\u7a0b\u5e8f\u90e8\u7f72\u5230\u670d\u52a1\u5668\u4e0a\u3002\u5e38\u89c1\u7684\u90e8\u7f72\u65b9\u5f0f\u5305\u62ec\u4f7f\u7528Nginx+uWSGI\u3001Gunicorn\u7b49\u3002\u53ef\u4ee5\u9009\u62e9\u4e91\u670d\u52a1\u5668\u6216\u865a\u62df\u4e3b\u673a\u8fdb\u884c\u90e8\u7f72\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u5bb9\u5668\u5316\u90e8\u7f72<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528Docker\u7b49\u5bb9\u5668\u5316\u6280\u672f\uff0c\u53ef\u4ee5\u5c06Python\u7a0b\u5e8f\u6253\u5305\u6210\u5bb9\u5668\u955c\u50cf\uff0c\u5e76\u5728\u4efb\u610f\u73af\u5883\u4e2d\u8fd0\u884c\u3002\u8fd9\u79cd\u65b9\u5f0f\u5177\u6709\u826f\u597d\u7684\u53ef\u79fb\u690d\u6027\u548c\u9694\u79bb\u6027\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u53d1\u5e03\u5230PyPI<\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8e\u901a\u7528\u7684Python\u5e93\u6216\u5de5\u5177\uff0c\u53ef\u4ee5\u5c06\u5176\u53d1\u5e03\u5230Python\u5305\u7ba1\u7406\u7cfb\u7edf\uff08PyPI\uff09\u3002\u901a\u8fc7\u7f16\u5199setup.py\u6587\u4ef6\u5e76\u4f7f\u7528\u76f8\u5173\u5de5\u5177\uff0c\u53ef\u4ee5\u5c06\u5305\u4e0a\u4f20\u5230PyPI\uff0c\u4f9b\u5176\u4ed6\u7528\u6237\u5b89\u88c5\u548c\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e00\u3001Python\u7a0b\u5e8f\u7684\u7ef4\u62a4\u548c\u4f18\u5316<\/h3>\n<\/p>\n<p><p>\u7a0b\u5e8f\u7684\u7ef4\u62a4\u548c\u4f18\u5316\u662f\u6301\u7eed\u7684\u8fc7\u7a0b\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u7ef4\u62a4\u548c\u4f18\u5316\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u4ee3\u7801\u91cd\u6784<\/h4>\n<\/p>\n<p><p>\u4ee3\u7801\u91cd\u6784\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002\u4f8b\u5982\uff0c\u63d0\u53d6\u91cd\u590d\u4ee3\u7801\u3001\u4f18\u5316\u51fd\u6570\u548c\u7c7b\u7ed3\u6784\u3001\u4f7f\u7528\u8bbe\u8ba1\u6a21\u5f0f\u7b49\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u6027\u80fd\u4f18\u5316<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u5206\u6790\u548c\u4f18\u5316\u7a0b\u5e8f\u7684\u6027\u80fd\uff0c\u53ef\u4ee5\u63d0\u9ad8\u8fd0\u884c\u6548\u7387\u3002\u5e38\u7528\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528\u9ad8\u6548\u7684\u6570\u636e\u7ed3\u6784\u3001\u907f\u514d\u91cd\u590d\u8ba1\u7b97\u3001\u4f7f\u7528\u591a\u7ebf\u7a0b\u6216\u591a\u8fdb\u7a0b\u7b49\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u9519\u8bef\u5904\u7406<\/h4>\n<\/p>\n<p><p>\u5b8c\u5584\u7684\u9519\u8bef\u5904\u7406\u53ef\u4ee5\u63d0\u9ad8\u7a0b\u5e8f\u7684\u7a33\u5b9a\u6027\u548c\u53ef\u9760\u6027\u3002\u901a\u8fc7\u4f7f\u7528try-except\u8bed\u53e5\u3001\u8bb0\u5f55\u65e5\u5fd7\u3001\u7f16\u5199\u5355\u5143\u6d4b\u8bd5\u7b49\uff0c\u53ef\u4ee5\u53ca\u65f6\u53d1\u73b0\u548c\u5904\u7406\u9519\u8bef\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u6587\u6863\u7f16\u5199<\/h4>\n<\/p>\n<p><p>\u5b8c\u5584\u7684\u6587\u6863\u53ef\u4ee5\u5e2e\u52a9\u5176\u4ed6\u5f00\u53d1\u8005\u7406\u89e3\u548c\u4f7f\u7528\u7a0b\u5e8f\u3002\u901a\u8fc7\u7f16\u5199\u6ce8\u91ca\u3001\u4f7f\u7528\u6587\u6863\u751f\u6210\u5de5\u5177\u3001\u7f16\u5199\u7528\u6237\u624b\u518c\u7b49\uff0c\u53ef\u4ee5\u63d0\u9ad8\u7a0b\u5e8f\u7684\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e8c\u3001Python\u7a0b\u5e8f\u7684\u5b89\u5168\u6027<\/h3>\n<\/p>\n<p><p>\u4fdd\u8bc1\u7a0b\u5e8f\u7684\u5b89\u5168\u6027\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u5b89\u5168\u6027\u63aa\u65bd\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u8f93\u5165\u9a8c\u8bc1<\/h4>\n<\/p>\n<p><p>\u5bf9\u7528\u6237\u8f93\u5165\u8fdb\u884c\u9a8c\u8bc1\u548c\u8fc7\u6ee4\uff0c\u53ef\u4ee5\u9632\u6b62SQL\u6ce8\u5165\u3001XSS\u653b\u51fb\u7b49\u5e38\u89c1\u7684\u5b89\u5168\u6f0f\u6d1e\u3002\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u3001\u767d\u540d\u5355\u7b49\u65b9\u6cd5\u8fdb\u884c\u9a8c\u8bc1\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u6570\u636e\u52a0\u5bc6<\/h4>\n<\/p>\n<p><p>\u5bf9\u654f\u611f\u6570\u636e\u8fdb\u884c\u52a0\u5bc6\u5b58\u50a8\u548c\u4f20\u8f93\uff0c\u53ef\u4ee5\u63d0\u9ad8\u6570\u636e\u7684\u5b89\u5168\u6027\u3002\u53ef\u4ee5\u4f7f\u7528\u5e38\u89c1\u7684\u52a0\u5bc6\u7b97\u6cd5\u5982AES\u3001RSA\u7b49\u8fdb\u884c\u52a0\u5bc6\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u6743\u9650\u63a7\u5236<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u8bbe\u7f6e\u5408\u9002\u7684\u6743\u9650\u63a7\u5236\uff0c\u53ef\u4ee5\u9632\u6b62\u672a\u6388\u6743\u7684\u8bbf\u95ee\u548c\u64cd\u4f5c\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u8eab\u4efd\u9a8c\u8bc1\u548c\u6388\u6743\u673a\u5236\u3001\u8bbe\u7f6e\u6587\u4ef6\u548c\u76ee\u5f55\u6743\u9650\u7b49\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u5b89\u5168\u66f4\u65b0<\/h4>\n<\/p>\n<p><p>\u53ca\u65f6\u66f4\u65b0\u7a0b\u5e8f\u548c\u4f9d\u8d56\u5e93\uff0c\u53ef\u4ee5\u4fee\u590d\u5df2\u77e5\u7684\u5b89\u5168\u6f0f\u6d1e\u3002\u53ef\u4ee5\u4f7f\u7528\u81ea\u52a8\u5316\u5de5\u5177\u76d1\u63a7\u548c\u7ba1\u7406\u4f9d\u8d56\u5e93\u7684\u66f4\u65b0\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e09\u3001Python\u7a0b\u5e8f\u7684\u6d4b\u8bd5<\/h3>\n<\/p>\n<p><p>\u6d4b\u8bd5\u662f\u4fdd\u8bc1\u7a0b\u5e8f\u8d28\u91cf\u7684\u91cd\u8981\u73af\u8282\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u6d4b\u8bd5\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u5355\u5143\u6d4b\u8bd5<\/h4>\n<\/p>\n<p><p>\u5355\u5143\u6d4b\u8bd5\u662f\u5bf9\u6700\u5c0f\u7684\u529f\u80fd\u5355\u5143\u8fdb\u884c\u6d4b\u8bd5\u3002\u901a\u8fc7\u7f16\u5199\u5355\u5143\u6d4b\u8bd5\uff0c\u53ef\u4ee5\u9a8c\u8bc1\u6bcf\u4e2a\u51fd\u6570\u548c\u7c7b\u7684\u6b63\u786e\u6027\u3002\u5e38\u7528\u7684\u5355\u5143\u6d4b\u8bd5\u6846\u67b6\u5305\u62ecunittest\u3001pytest\u7b49\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u96c6\u6210\u6d4b\u8bd5<\/h4>\n<\/p>\n<p><p>\u96c6\u6210\u6d4b\u8bd5\u662f\u5bf9\u591a\u4e2a\u529f\u80fd\u6a21\u5757\u8fdb\u884c\u6d4b\u8bd5\u3002\u901a\u8fc7\u7f16\u5199\u96c6\u6210\u6d4b\u8bd5\uff0c\u53ef\u4ee5\u9a8c\u8bc1\u6a21\u5757\u4e4b\u95f4\u7684\u4ea4\u4e92\u548c\u6574\u4f53\u529f\u80fd\u7684\u6b63\u786e\u6027\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u7cfb\u7edf\u6d4b\u8bd5<\/h4>\n<\/p>\n<p><p>\u7cfb\u7edf\u6d4b\u8bd5\u662f\u5bf9\u6574\u4e2a\u7cfb\u7edf\u8fdb\u884c\u6d4b\u8bd5\u3002\u901a\u8fc7\u7f16\u5199\u7cfb\u7edf\u6d4b\u8bd5\uff0c\u53ef\u4ee5\u9a8c\u8bc1\u7cfb\u7edf\u7684\u5b8c\u6574\u6027\u548c\u6027\u80fd\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u56de\u5f52\u6d4b\u8bd5<\/h4>\n<\/p>\n<p><p>\u56de\u5f52\u6d4b\u8bd5\u662f\u5bf9\u4fee\u6539\u540e\u7684\u7a0b\u5e8f\u8fdb\u884c\u6d4b\u8bd5\u3002\u901a\u8fc7\u7f16\u5199\u56de\u5f52\u6d4b\u8bd5\uff0c\u53ef\u4ee5\u9a8c\u8bc1\u4fee\u6539\u662f\u5426\u5f15\u5165\u4e86\u65b0\u7684\u9519\u8bef\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u56db\u3001Python\u7a0b\u5e8f\u7684\u6587\u6863\u7f16\u5199<\/h3>\n<\/p>\n<p><p>\u7f16\u5199\u6587\u6863\u53ef\u4ee5\u5e2e\u52a9\u5176\u4ed6\u5f00\u53d1\u8005\u7406\u89e3\u548c\u4f7f\u7528\u7a0b\u5e8f\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u6587\u6863\u7f16\u5199\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u6ce8\u91ca<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u5728\u4ee3\u7801\u4e2d\u6dfb\u52a0\u6ce8\u91ca\uff0c\u53ef\u4ee5\u89e3\u91ca\u4ee3\u7801\u7684\u529f\u80fd\u548c\u903b\u8f91\u3002\u6ce8\u91ca\u5e94\u8be5\u7b80\u6d01\u660e\u4e86\uff0c\u907f\u514d\u8fc7\u591a\u7684\u89e3\u91ca\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u6587\u6863\u5b57\u7b26\u4e32<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u5728\u51fd\u6570\u548c\u7c7b\u4e2d\u6dfb\u52a0\u6587\u6863\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u751f\u6210\u81ea\u52a8\u5316\u6587\u6863\u3002\u5e38\u7528\u7684\u6587\u6863\u5b57\u7b26\u4e32\u683c\u5f0f\u5305\u62ecreStructuredText\u3001Google\u98ce\u683c\u7b49\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u6587\u6863\u751f\u6210\u5de5\u5177<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528\u6587\u6863\u751f\u6210\u5de5\u5177\u53ef\u4ee5\u81ea\u52a8\u751f\u6210API\u6587\u6863\u3002\u5e38\u7528\u7684\u5de5\u5177\u5305\u62ecSphinx\u3001Doxygen\u7b49\u3002\u901a\u8fc7\u7f16\u5199\u914d\u7f6e\u6587\u4ef6\u548c\u6587\u6863\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u751f\u6210\u8be6\u7ec6\u7684API\u6587\u6863\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u7528\u6237\u624b\u518c<\/h4>\n<\/p>\n<p><p>\u7f16\u5199\u7528\u6237\u624b\u518c\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237\u7406\u89e3\u548c\u4f7f\u7528\u7a0b\u5e8f\u3002\u7528\u6237\u624b\u518c\u53ef\u4ee5\u5305\u62ec\u5b89\u88c5\u6307\u5357\u3001\u4f7f\u7528\u8bf4\u660e\u3001\u5e38\u89c1\u95ee\u9898\u89e3\u7b54\u7b49\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e94\u3001Python\u7a0b\u5e8f\u7684\u7248\u672c\u63a7\u5236<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u7248\u672c\u63a7\u5236\u5de5\u5177\u53ef\u4ee5\u7ba1\u7406\u4ee3\u7801\u7248\u672c\u548c\u534f\u4f5c\u5f00\u53d1\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u7248\u672c\u63a7\u5236\u5de5\u5177\u548c\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001Git<\/h4>\n<\/p>\n<p><p>Git\u662f\u76ee\u524d\u6700\u6d41\u884c\u7684\u7248\u672c\u63a7\u5236\u5de5\u5177\u3002\u901a\u8fc7\u4f7f\u7528Git\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u4ee3\u7801\u63d0\u4ea4\u3001\u56de\u6eda\u3001\u5206\u652f\u7ba1\u7406\u7b49\u64cd\u4f5c\u3002\u5e38\u7528\u7684Git\u5e73\u53f0\u5305\u62ecGitHub\u3001GitLab\u3001Bitbucket\u7b49\u3002<\/p>\n<\/p>\n<p><h4>2\u3001SVN<\/h4>\n<\/p>\n<p><p>SVN\uff08Subversion\uff09\u662f\u4e00\u79cd\u96c6\u4e2d\u5f0f\u7248\u672c\u63a7\u5236\u5de5\u5177\u3002\u76f8\u6bd4Git\uff0cSVN\u66f4\u9002\u5408\u5c0f\u89c4\u6a21\u56e2\u961f\u548c\u5355\u4e00\u9879\u76ee\u7684\u7ba1\u7406\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u5206\u652f\u7ba1\u7406<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528\u5206\u652f\u7ba1\u7406\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u5e76\u884c\u5f00\u53d1\u548c\u7248\u672c\u63a7\u5236\u3002\u5e38\u7528\u7684\u5206\u652f\u7ba1\u7406\u7b56\u7565\u5305\u62ecGit Flow\u3001GitHub Flow\u7b49\u3002<\/p>\n<\/p>\n<p><h4>4\u3001<a href=\"https:\/\/docs.pingcode.com\/code-review\" target=\"_blank\">\u4ee3\u7801\u5ba1\u67e5<\/a><\/h4>\n<\/p>\n<p><p>\u4ee3\u7801\u5ba1\u67e5\u662f\u4fdd\u8bc1\u4ee3\u7801\u8d28\u91cf\u7684\u91cd\u8981\u73af\u8282\u3002\u901a\u8fc7\u8fdb\u884c\u4ee3\u7801\u5ba1\u67e5\uff0c\u53ef\u4ee5\u53d1\u73b0\u6f5c\u5728\u7684\u95ee\u9898\u548c\u4f18\u5316\u70b9\u3002\u5e38\u7528\u7684\u4ee3\u7801\u5ba1\u67e5\u5de5\u5177\u5305\u62ecGerrit\u3001Phabricator\u7b49\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u516d\u3001Python\u7a0b\u5e8f\u7684\u90e8\u7f72\u548c\u53d1\u5e03<\/h3>\n<\/p>\n<p><p>\u5c06\u5f00\u53d1\u597d\u7684Python\u7a0b\u5e8f\u90e8\u7f72\u548c\u53d1\u5e03\u662f\u6700\u540e\u4e00\u6b65\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u90e8\u7f72\u548c\u53d1\u5e03\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u672c\u5730\u8fd0\u884c<\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8e\u7b80\u5355\u7684\u811a\u672c\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728\u672c\u5730\u8fd0\u884c\u548c\u6d4b\u8bd5\u3002\u5982\u679c\u9700\u8981\u5b9a\u671f\u8fd0\u884c\uff0c\u53ef\u4ee5\u4f7f\u7528\u5b9a\u65f6\u4efb\u52a1\u6216\u4efb\u52a1\u8ba1\u5212\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u670d\u52a1\u5668\u90e8\u7f72<\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8eWeb\u5e94\u7528\uff0c\u53ef\u4ee5\u5c06\u7a0b\u5e8f\u90e8\u7f72\u5230\u670d\u52a1\u5668\u4e0a\u3002\u5e38\u89c1\u7684\u90e8\u7f72\u65b9\u5f0f\u5305\u62ec\u4f7f\u7528Nginx+uWSGI\u3001Gunicorn\u7b49\u3002\u53ef\u4ee5\u9009\u62e9\u4e91\u670d\u52a1\u5668\u6216\u865a\u62df\u4e3b\u673a\u8fdb\u884c\u90e8\u7f72\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u5bb9\u5668\u5316\u90e8\u7f72<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528Docker\u7b49\u5bb9\u5668\u5316\u6280\u672f\uff0c\u53ef\u4ee5\u5c06Python\u7a0b\u5e8f\u6253\u5305\u6210\u5bb9\u5668\u955c\u50cf\uff0c\u5e76\u5728\u4efb\u610f\u73af\u5883\u4e2d\u8fd0\u884c\u3002\u8fd9\u79cd\u65b9\u5f0f\u5177\u6709\u826f\u597d\u7684\u53ef\u79fb\u690d\u6027\u548c\u9694\u79bb\u6027\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u53d1\u5e03\u5230PyPI<\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8e\u901a\u7528\u7684Python\u5e93\u6216\u5de5\u5177\uff0c\u53ef\u4ee5\u5c06\u5176\u53d1\u5e03\u5230Python\u5305\u7ba1\u7406\u7cfb\u7edf\uff08PyPI\uff09\u3002\u901a\u8fc7\u7f16\u5199setup.py\u6587\u4ef6\u5e76\u4f7f\u7528\u76f8\u5173\u5de5\u5177\uff0c\u53ef\u4ee5\u5c06\u5305\u4e0a\u4f20\u5230PyPI\uff0c\u4f9b\u5176\u4ed6\u7528\u6237\u5b89\u88c5\u548c\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><h3>\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u8fd0\u884cPython\u5199\u5165\u7a0b\u5e8f\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u3001\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3001\u811a\u672c\u6587\u4ef6\u7b49\u591a\u79cd\u65b9\u5f0f\u8fdb\u884c\u3002\u5b89\u88c5Python\u73af\u5883\u3001\u7f16\u5199Python\u811a\u672c\u3001\u901a\u8fc7\u547d\u4ee4\u884c\u6216IDE\u8fd0\u884c\u811a\u672c\u662f\u6700\u57fa\u672c\u7684\u6b65\u9aa4\u3002\u9664\u4e86\u8fd9\u4e9b\u5e38\u89c1\u7684\u65b9\u6cd5\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7\u4efb\u52a1\u8ba1\u5212\u7a0b\u5e8f\u6216cron\u5b9a\u65f6\u4efb\u52a1\u3001Web\u670d\u52a1\u5668\u3001\u5bb9\u5668\u5316\u6280\u672f\u7b49\u65b9\u5f0f\u8fd0\u884cPython\u7a0b\u5e8f\u3002\u4e0d\u540c\u7684\u8fd0\u884c\u65b9\u5f0f\u9002\u7528\u4e8e\u4e0d\u540c\u7684\u5e94\u7528\u573a\u666f\uff0c\u9009\u62e9\u5408\u9002\u7684\u65b9\u5f0f\u53ef\u4ee5\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u548c\u7a0b\u5e8f\u6027\u80fd\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Windows\u4e0a\u8fd0\u884cPython\u7a0b\u5e8f\uff1f<\/strong><br \/>\u5728Windows\u7cfb\u7edf\u4e0a\u8fd0\u884cPython\u7a0b\u5e8f\u76f8\u5bf9\u7b80\u5355\u3002\u9996\u5148\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86Python\uff0c\u5e76\u5c06\u5176\u8def\u5f84\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u63a5\u4e0b\u6765\uff0c\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u5bfc\u822a\u5230\u5b58\u50a8Python\u6587\u4ef6\u7684\u76ee\u5f55\uff0c\u4f7f\u7528\u547d\u4ee4<code>python \u6587\u4ef6\u540d.py<\/code>\u6765\u8fd0\u884c\u7a0b\u5e8f\u3002\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662fPython 3\uff0c\u53ef\u80fd\u9700\u8981\u4f7f\u7528<code>python3 \u6587\u4ef6\u540d.py<\/code>\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Mac\u6216Linux\u4e0a\u8fd0\u884cPython\u7a0b\u5e8f\uff1f<\/strong><br \/>\u5728Mac\u6216Linux\u7cfb\u7edf\u4e0a\uff0c\u6253\u5f00\u7ec8\u7aef\uff0c\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u3002\u5bfc\u822a\u5230\u7a0b\u5e8f\u6240\u5728\u7684\u76ee\u5f55\uff0c\u4f7f\u7528\u547d\u4ee4<code>python3 \u6587\u4ef6\u540d.py<\/code>\u6765\u8fd0\u884c\u4f60\u7684Python\u7a0b\u5e8f\u3002\u786e\u4fdd\u6587\u4ef6\u5177\u6709\u53ef\u6267\u884c\u6743\u9650\uff0c\u5982\u679c\u6ca1\u6709\uff0c\u53ef\u4ee5\u4f7f\u7528<code>chmod +x \u6587\u4ef6\u540d.py<\/code>\u6765\u8d4b\u4e88\u6743\u9650\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u4e2d\u8fd0\u884cPython\u7a0b\u5e8f\uff1f<\/strong><br \/>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff0c\u5982PyCharm\u3001VS Code\u6216Jupyter Notebook\uff0c\u4f60\u53ef\u4ee5\u76f4\u63a5\u5728IDE\u4e2d\u6253\u5f00\u4f60\u7684Python\u6587\u4ef6\uff0c\u5e76\u627e\u5230\u8fd0\u884c\u6309\u94ae\u6216\u4f7f\u7528\u5feb\u6377\u952e\uff08\u5982Shift+F10\uff09\u6765\u6267\u884c\u7a0b\u5e8f\u3002\u8fd9\u79cd\u65b9\u5f0f\u901a\u5e38\u63d0\u4f9b\u8c03\u8bd5\u5de5\u5177\uff0c\u4fbf\u4e8e\u4f60\u5feb\u901f\u68c0\u67e5\u4ee3\u7801\u7684\u8fd0\u884c\u60c5\u51b5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u8fd0\u884cPython\u5199\u5165\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u547d\u4ee4\u884c\u3001\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3001\u811a\u672c\u6587\u4ef6\u7b49\u591a\u79cd\u65b9\u5f0f\u8fdb\u884c\u3002\u5177\u4f53\u6b65\u9aa4\u5305\u62ec\uff1a [&hellip;]","protected":false},"author":3,"featured_media":1160650,"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\/1160642"}],"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=1160642"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1160642\/revisions"}],"predecessor-version":[{"id":1160654,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1160642\/revisions\/1160654"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1160650"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1160642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1160642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1160642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}