{"id":975019,"date":"2024-12-27T06:09:53","date_gmt":"2024-12-26T22:09:53","guid":{"rendered":""},"modified":"2024-12-27T06:09:56","modified_gmt":"2024-12-26T22:09:56","slug":"%e5%a6%82%e4%bd%95%e6%8e%a8%e5%87%bapython%e4%ba%a4%e4%ba%92%e7%8e%af%e5%a2%83","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/975019.html","title":{"rendered":"\u5982\u4f55\u63a8\u51fapython\u4ea4\u4e92\u73af\u5883"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24200438\/fc7d2d99-0185-4732-84f4-8c0100ac1935.webp\" alt=\"\u5982\u4f55\u63a8\u51fapython\u4ea4\u4e92\u73af\u5883\" \/><\/p>\n<p><p> <strong>\u63a8\u51faPython\u4ea4\u4e92\u73af\u5883\u7684\u5173\u952e\u6b65\u9aa4\u5305\u62ec\uff1a\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u3001\u914d\u7f6e\u73af\u5883\u3001\u5b89\u88c5\u5fc5\u8981\u7684\u5e93\u3001\u719f\u6089\u57fa\u672c\u547d\u4ee4\u548c\u64cd\u4f5c\u3002<\/strong>\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u662f\u63a8\u51faPython\u4ea4\u4e92\u73af\u5883\u7684\u57fa\u7840\uff0c\u5e38\u7528\u7684\u5de5\u5177\u5305\u62ecJupyter Notebook\u3001IPython\u3001PyCharm\u7b49\u3002\u914d\u7f6e\u73af\u5883\u662f\u786e\u4fddPython\u4ea4\u4e92\u73af\u5883\u80fd\u591f\u6b63\u5e38\u8fd0\u884c\u7684\u91cd\u8981\u6b65\u9aa4\uff0c\u5305\u62ec\u8bbe\u7f6ePython\u8def\u5f84\u3001\u5b89\u88c5\u865a\u62df\u73af\u5883\u7b49\u3002\u5b89\u88c5\u5fc5\u8981\u7684\u5e93\u53ef\u4ee5\u589e\u5f3aPython\u73af\u5883\u7684\u529f\u80fd\u6027\uff0c\u4f8b\u5982NumPy\u3001Pandas\u3001Matplotlib\u7b49\u5e93\u3002\u719f\u6089\u57fa\u672c\u547d\u4ee4\u548c\u64cd\u4f5c\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237\u66f4\u597d\u5730\u5229\u7528Python\u4ea4\u4e92\u73af\u5883\u8fdb\u884c\u6570\u636e\u5206\u6790\u3001\u53ef\u89c6\u5316\u7b49\u4efb\u52a1\u3002\u4e0b\u9762\u5c06\u5bf9\u5176\u4e2d\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u8fdb\u884c\u8be6\u7ec6\u63cf\u8ff0\u3002<\/p>\n<\/p>\n<p><p>\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\uff1a\u5728\u63a8\u51faPython\u4ea4\u4e92\u73af\u5883\u65f6\uff0c\u5de5\u5177\u7684\u9009\u62e9\u975e\u5e38\u5173\u952e\uff0c\u56e0\u4e3a\u4e0d\u540c\u7684\u5de5\u5177\u9002\u7528\u4e8e\u4e0d\u540c\u7684\u4f7f\u7528\u573a\u666f\u3002Jupyter Notebook\u662f\u4e00\u79cd\u57fa\u4e8eWeb\u7684\u4ea4\u4e92\u5f0f\u5f00\u53d1\u73af\u5883\uff0c\u9002\u5408\u4e8e\u6570\u636e\u5206\u6790\u548c\u53ef\u89c6\u5316\uff0c\u652f\u6301Markdown\u683c\u5f0f\u7684\u6587\u6863\u64b0\u5199\uff0c\u4f7f\u5f97\u7528\u6237\u53ef\u4ee5\u65b9\u4fbf\u5730\u8bb0\u5f55\u5206\u6790\u8fc7\u7a0b\u548c\u7ed3\u679c\u3002IPython\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u4ea4\u4e92\u5f0fPython\u547d\u4ee4\u884c\uff0c\u9002\u5408\u4e8e\u65e5\u5e38\u7684Python\u7f16\u7a0b\u548c\u8c03\u8bd5\u3002PyCharm\u662f\u4e00\u6b3e\u4e13\u4e1a\u7684Python\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\uff0c\u9002\u5408\u4e8e\u5927\u578b\u9879\u76ee\u7684\u5f00\u53d1\u548c\u7ba1\u7406\uff0c\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u4ee3\u7801\u7f16\u8f91\u3001\u8c03\u8bd5\u548c\u7248\u672c\u63a7\u5236\u529f\u80fd\u3002\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\uff0c\u5e76\u7b80\u5316Python\u4ea4\u4e92\u73af\u5883\u7684\u63a8\u51fa\u8fc7\u7a0b\u3002<\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u63a2\u8ba8\u63a8\u51faPython\u4ea4\u4e92\u73af\u5883\u7684\u6bcf\u4e2a\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177<\/h3>\n<\/p>\n<p><p>\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u662f\u63a8\u51faPython\u4ea4\u4e92\u73af\u5883\u7684\u7b2c\u4e00\u6b65\u3002\u4e0d\u540c\u7684\u5de5\u5177\u6709\u4e0d\u540c\u7684\u7279\u70b9\u548c\u9002\u7528\u573a\u666f\uff0c\u56e0\u6b64\u4e86\u89e3\u5b83\u4eec\u7684\u4f18\u7f3a\u70b9\u6709\u52a9\u4e8e\u9009\u62e9\u6700\u9002\u5408\u81ea\u5df1\u9700\u6c42\u7684\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><h4>1. Jupyter Notebook<\/h4>\n<\/p>\n<p><p>Jupyter Notebook\u662f\u4e00\u79cd\u57fa\u4e8eWeb\u7684\u4ea4\u4e92\u5f0f\u5f00\u53d1\u73af\u5883\uff0c\u5e7f\u6cdb\u7528\u4e8e\u6570\u636e\u79d1\u5b66\u3001<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u548c\u5b66\u672f\u7814\u7a76\u9886\u57df\u3002\u5b83\u5141\u8bb8\u7528\u6237\u5728\u4e00\u4e2a\u6587\u6863\u4e2d\u7f16\u5199\u4ee3\u7801\u3001\u8fd0\u884c\u4ee3\u7801\u3001\u67e5\u770b\u8f93\u51fa\u5e76\u64b0\u5199Markdown\u683c\u5f0f\u7684\u6587\u672c\uff0c\u8fd9\u5bf9\u4e8e\u8bb0\u5f55\u6570\u636e\u5206\u6790\u8fc7\u7a0b\u548c\u7ed3\u679c\u975e\u5e38\u65b9\u4fbf\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u4f18\u70b9<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\uff0c\u9664\u4e86Python\uff0c\u8fd8\u652f\u6301R\u3001Julia\u7b49\u3002<\/li>\n<li>\u65b9\u4fbf\u7684\u6570\u636e\u53ef\u89c6\u5316\u529f\u80fd\uff0c\u53ef\u4ee5\u76f4\u63a5\u5d4c\u5165\u56fe\u8868\u3002<\/li>\n<li>\u9002\u5408\u4e8e\u6f14\u793a\u548c\u6559\u5b66\uff0c\u6613\u4e8e\u5206\u4eab\u548c\u534f\u4f5c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u7f3a\u70b9<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u5bf9\u4e8e\u5927\u578b\u9879\u76ee\u7684\u4ee3\u7801\u7ba1\u7406\u548c\u7248\u672c\u63a7\u5236\u4e0d\u5982IDE\u7075\u6d3b\u3002<\/li>\n<li>\u4f9d\u8d56\u4e8eWeb\u6d4f\u89c8\u5668\uff0c\u53ef\u80fd\u5728\u79bb\u7ebf\u73af\u5883\u4e0b\u4f7f\u7528\u53d7\u9650\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><h4>2. IPython<\/h4>\n<\/p>\n<p><p>IPython\u662f\u4e00\u4e2a\u589e\u5f3a\u7684Python\u4ea4\u4e92\u5f0f\u547d\u4ee4\u884c\uff0c\u6bd4\u9ed8\u8ba4\u7684Python Shell\u529f\u80fd\u66f4\u5f3a\u5927\u3002\u5b83\u652f\u6301\u81ea\u52a8\u8865\u5168\u3001\u8bed\u6cd5\u9ad8\u4eae\u3001\u9b54\u6cd5\u547d\u4ee4\u7b49\u529f\u80fd\uff0c\u4f7f\u5f97Python\u7f16\u7a0b\u66f4\u52a0\u4fbf\u6377\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u4f18\u70b9<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u8f7b\u91cf\u7ea7\uff0c\u542f\u52a8\u5feb\uff0c\u9002\u5408\u5feb\u901f\u6d4b\u8bd5\u548c\u8c03\u8bd5\u4ee3\u7801\u3002<\/li>\n<li>\u9b54\u6cd5\u547d\u4ee4\uff08Magic Commands\uff09\u63d0\u4f9b\u4e86\u8bb8\u591a\u4fbf\u6377\u7684\u529f\u80fd\uff0c\u4f8b\u5982\u65f6\u95f4\u6d4b\u91cf\u3001\u5185\u5b58\u4f7f\u7528\u5206\u6790\u7b49\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u7f3a\u70b9<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4e0d\u9002\u5408\u5904\u7406\u590d\u6742\u9879\u76ee\u548c\u591a\u6587\u4ef6\u7ba1\u7406\u3002<\/li>\n<li>\u4e0d\u5982Jupyter Notebook\u76f4\u89c2\u7684\u53ef\u89c6\u5316\u548c\u6587\u6863\u8bb0\u5f55\u529f\u80fd\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><h4>3. PyCharm<\/h4>\n<\/p>\n<p><p>PyCharm\u662f\u4e00\u6b3e\u7531JetBr<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ns\u5f00\u53d1\u7684Python\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\uff0c\u4ee5\u5176\u5f3a\u5927\u7684\u529f\u80fd\u548c\u7075\u6d3b\u7684\u63d2\u4ef6\u7cfb\u7edf\u53d7\u5230\u5f00\u53d1\u8005\u7684\u559c\u7231\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u4f18\u70b9<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u5f3a\u5927\u7684\u4ee3\u7801\u7f16\u8f91\u548c\u8c03\u8bd5\u529f\u80fd\uff0c\u652f\u6301\u91cd\u6784\u548c\u667a\u80fd\u63d0\u793a\u3002<\/li>\n<li>\u96c6\u6210\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff08\u5982Git\uff09\uff0c\u9002\u5408\u5927\u578b\u9879\u76ee\u5f00\u53d1\u3002<\/li>\n<li>\u4e30\u5bcc\u7684\u63d2\u4ef6\u548c\u6269\u5c55\uff0c\u652f\u6301Web\u5f00\u53d1\u3001\u6570\u636e\u79d1\u5b66\u7b49\u591a\u79cd\u5e94\u7528\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u7f3a\u70b9<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u8d44\u6e90\u5360\u7528\u8f83\u9ad8\uff0c\u53ef\u80fd\u5728\u4f4e\u914d\u7f6e\u7535\u8111\u4e0a\u8fd0\u884c\u4e0d\u591f\u6d41\u7545\u3002<\/li>\n<li>\u5b66\u4e60\u66f2\u7ebf\u76f8\u5bf9\u8f83\u9661\uff0c\u5bf9\u4e8e\u65b0\u624b\u53ef\u80fd\u9700\u8981\u4e00\u4e9b\u65f6\u95f4\u9002\u5e94\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><h3>\u4e8c\u3001\u914d\u7f6e\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u5728\u9009\u62e9\u597d\u5de5\u5177\u4e4b\u540e\uff0c\u4e0b\u4e00\u6b65\u5c31\u662f\u914d\u7f6ePython\u4ea4\u4e92\u73af\u5883\u3002\u8fd9\u4e00\u6b65\u9aa4\u5305\u62ec\u5b89\u88c5Python\u3001\u8bbe\u7f6e\u8def\u5f84\u3001\u521b\u5efa\u865a\u62df\u73af\u5883\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5Python<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u9700\u8981\u5728\u7cfb\u7edf\u4e0a\u5b89\u88c5Python\u3002\u53ef\u4ee5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u9002\u5408\u81ea\u5df1\u64cd\u4f5c\u7cfb\u7edf\u7684\u5b89\u88c5\u5305\u3002\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u786e\u4fdd\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u76f4\u63a5\u4f7f\u7528Python\u547d\u4ee4\u3002<\/p>\n<\/p>\n<p><h4>2. \u8bbe\u7f6e\u8def\u5f84<\/h4>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u201c\u7cfb\u7edf\u5c5e\u6027\u201d-&gt;\u201c\u73af\u5883\u53d8\u91cf\u201d\u6765\u8bbe\u7f6ePython\u7684\u8def\u5f84\u3002\u5728Linux\u548cmacOS\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91<code>.bashrc<\/code>\u6216<code>.zshrc<\/code>\u6587\u4ef6\uff0c\u5c06Python\u8def\u5f84\u6dfb\u52a0\u5230<code>PATH<\/code>\u53d8\u91cf\u4e2d\u3002<\/p>\n<\/p>\n<p><h4>3. \u521b\u5efa\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u9694\u79bb\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\uff0c\u907f\u514d\u7248\u672c\u51b2\u7a81\u3002\u53ef\u4ee5\u4f7f\u7528<code>venv<\/code>\u6a21\u5757\u6765\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u5728Windows\u7cfb\u7edf\u4e2d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">myenv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u5728Linux\u548cmacOS\u7cfb\u7edf\u4e2d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><h3>\u4e09\u3001\u5b89\u88c5\u5fc5\u8981\u7684\u5e93<\/h3>\n<\/p>\n<p><p>\u5728\u914d\u7f6e\u597d\u73af\u5883\u540e\uff0c\u9700\u8981\u5b89\u88c5\u5fc5\u8981\u7684Python\u5e93\uff0c\u4ee5\u4fbf\u5728\u4ea4\u4e92\u73af\u5883\u4e2d\u6267\u884c\u5404\u79cd\u4efb\u52a1\u3002\u5e38\u7528\u7684\u5e93\u5305\u62ec\u4f46\u4e0d\u9650\u4e8eNumPy\u3001Pandas\u3001Matplotlib\u3001Scikit-learn\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1. NumPy<\/h4>\n<\/p>\n<p><p>NumPy\u662fPython\u4e2d\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u7684\u57fa\u7840\u5e93\uff0c\u63d0\u4f9b\u4e86\u652f\u6301\u591a\u7ef4\u6570\u7ec4\u548c\u77e9\u9635\u8fd0\u7b97\u7684\u9ad8\u6548\u63a5\u53e3\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u5b89\u88c5NumPy\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528NumPy\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u6570\u503c\u8ba1\u7b97\u548c\u7ebf\u6027\u4ee3\u6570\u64cd\u4f5c\uff0c\u662f\u6570\u636e\u5206\u6790\u548c\u673a\u5668\u5b66\u4e60\u7684\u57fa\u7840\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h4>2. Pandas<\/h4>\n<\/p>\n<p><p>Pandas\u662f\u7528\u4e8e\u6570\u636e\u64cd\u4f5c\u548c\u5206\u6790\u7684\u9ad8\u7ea7\u5e93\uff0c\u652f\u6301\u6570\u636e\u6e05\u6d17\u3001\u53d8\u6362\u3001\u5408\u5e76\u3001\u5206\u7ec4\u7b49\u591a\u79cd\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u5b89\u88c5Pandas\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>Pandas\u63d0\u4f9b\u4e86DataFrame\u548cSeries\u6570\u636e\u7ed3\u6784\uff0c\u53ef\u4ee5\u9ad8\u6548\u5730\u5904\u7406\u7ed3\u6784\u5316\u6570\u636e\uff0c\u5e7f\u6cdb\u7528\u4e8e\u6570\u636e\u5206\u6790\u548c\u9884\u5904\u7406\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h4>3. Matplotlib<\/h4>\n<\/p>\n<p><p>Matplotlib\u662fPython\u4e2d\u6700\u5e38\u7528\u7684\u6570\u636e\u53ef\u89c6\u5316\u5e93\uff0c\u80fd\u591f\u521b\u5efa\u9759\u6001\u3001\u52a8\u6001\u548c\u4ea4\u4e92\u5f0f\u56fe\u8868\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u5b89\u88c5Matplotlib\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install matplotlib<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>Matplotlib\u652f\u6301\u591a\u79cd\u56fe\u8868\u7c7b\u578b\uff0c\u5305\u62ec\u6298\u7ebf\u56fe\u3001\u67f1\u72b6\u56fe\u3001\u6563\u70b9\u56fe\u3001\u997c\u56fe\u7b49\uff0c\u662f\u6570\u636e\u53ef\u89c6\u5316\u7684\u5229\u5668\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h4>4. Scikit-learn<\/h4>\n<\/p>\n<p><p>Scikit-learn\u662fPython\u4e2d\u7528\u4e8e\u673a\u5668\u5b66\u4e60\u7684\u5e93\uff0c\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u7b97\u6cd5\u548c\u5de5\u5177\uff0c\u7528\u4e8e\u5206\u7c7b\u3001\u56de\u5f52\u3001\u805a\u7c7b\u3001\u964d\u7ef4\u7b49\u4efb\u52a1\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u5b89\u88c5Scikit-learn\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install scikit-learn<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>Scikit-learn\u7684\u63a5\u53e3\u7b80\u6d01\u7edf\u4e00\uff0c\u6613\u4e8e\u5b66\u4e60\u548c\u4f7f\u7528\uff0c\u9002\u5408\u4e8e\u5404\u7c7b\u673a\u5668\u5b66\u4e60\u4efb\u52a1\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h3>\u56db\u3001\u719f\u6089\u57fa\u672c\u547d\u4ee4\u548c\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>\u5728\u63a8\u51faPython\u4ea4\u4e92\u73af\u5883\u65f6\uff0c\u719f\u6089\u57fa\u672c\u547d\u4ee4\u548c\u64cd\u4f5c\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237\u66f4\u597d\u5730\u5229\u7528\u73af\u5883\u8fdb\u884c\u5404\u79cd\u4efb\u52a1\u3002<\/p>\n<\/p>\n<p><h4>1. \u57fa\u672c\u547d\u4ee4<\/h4>\n<\/p>\n<p><p>\u5728Python\u4ea4\u4e92\u73af\u5883\u4e2d\uff0c\u5e38\u7528\u7684\u547d\u4ee4\u5305\u62ec\u53d8\u91cf\u8d4b\u503c\u3001\u51fd\u6570\u5b9a\u4e49\u3001\u6761\u4ef6\u5224\u65ad\u3001\u5faa\u73af\u7b49\u3002\u638c\u63e1\u8fd9\u4e9b\u57fa\u672c\u547d\u4ee4\u662f\u7f16\u5199Python\u4ee3\u7801\u7684\u57fa\u7840\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u53d8\u91cf\u8d4b\u503c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">a = 10<\/p>\n<p>b = 20<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u51fd\u6570\u5b9a\u4e49\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def add(x, y):<\/p>\n<p>    return x + y<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u6761\u4ef6\u5224\u65ad\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">if a &gt; b:<\/p>\n<p>    print(&quot;a is greater than b&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(&quot;a is not greater than b&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u5faa\u73af\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">for i in range(5):<\/p>\n<p>    print(i)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><h4>2. \u6570\u636e\u64cd\u4f5c<\/h4>\n<\/p>\n<p><p>\u5728Python\u4ea4\u4e92\u73af\u5883\u4e2d\uff0c\u6570\u636e\u64cd\u4f5c\u662f\u5e38\u89c1\u7684\u4efb\u52a1\u4e4b\u4e00\u3002\u5e38\u7528\u7684\u6570\u636e\u64cd\u4f5c\u5305\u62ec\u6570\u7ec4\u64cd\u4f5c\u3001\u6570\u636e\u6e05\u6d17\u3001\u6570\u636e\u53d8\u6362\u7b49\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u6570\u7ec4\u64cd\u4f5c\uff1a<\/p>\n<\/p>\n<p><p>\u4f7f\u7528NumPy\u8fdb\u884c\u6570\u7ec4\u64cd\u4f5c\uff0c\u4f8b\u5982\u521b\u5efa\u6570\u7ec4\u3001\u6570\u7ec4\u8fd0\u7b97\u3001\u6570\u7ec4\u5207\u7247\u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>arr = np.array([1, 2, 3, 4, 5])<\/p>\n<p>print(arr + 10)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u6570\u636e\u6e05\u6d17\uff1a<\/p>\n<\/p>\n<p><p>\u4f7f\u7528Pandas\u8fdb\u884c\u6570\u636e\u6e05\u6d17\uff0c\u4f8b\u5982\u7f3a\u5931\u503c\u5904\u7406\u3001\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>df = pd.DataFrame({&#39;A&#39;: [1, 2, None], &#39;B&#39;: [4, None, 6]})<\/p>\n<p>df.fillna(0, inplace=True)<\/p>\n<p>print(df)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u6570\u636e\u53d8\u6362\uff1a<\/p>\n<\/p>\n<p><p>\u4f7f\u7528Pandas\u8fdb\u884c\u6570\u636e\u53d8\u6362\uff0c\u4f8b\u5982\u6570\u636e\u805a\u5408\u3001\u6570\u636e\u900f\u89c6\u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">df = pd.DataFrame({&#39;A&#39;: [&#39;foo&#39;, &#39;bar&#39;, &#39;foo&#39;, &#39;bar&#39;],<\/p>\n<p>                   &#39;B&#39;: [&#39;one&#39;, &#39;one&#39;, &#39;two&#39;, &#39;two&#39;],<\/p>\n<p>                   &#39;C&#39;: [1, 2, 3, 4]})<\/p>\n<p>result = df.pivot_table(index=&#39;A&#39;, columns=&#39;B&#39;, values=&#39;C&#39;, aggfunc=&#39;sum&#39;)<\/p>\n<p>print(result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u7528\u6237\u53ef\u4ee5\u6210\u529f\u63a8\u51faPython\u4ea4\u4e92\u73af\u5883\uff0c\u5e76\u5f00\u59cb\u8fdb\u884c\u6570\u636e\u5206\u6790\u3001\u53ef\u89c6\u5316\u548c\u673a\u5668\u5b66\u4e60\u7b49\u4efb\u52a1\u3002\u719f\u6089\u5de5\u5177\u3001\u914d\u7f6e\u73af\u5883\u3001\u5b89\u88c5\u5e93\u548c\u638c\u63e1\u57fa\u672c\u547d\u4ee4\u64cd\u4f5c\u662f\u786e\u4fddPython\u4ea4\u4e92\u73af\u5883\u987a\u5229\u8fd0\u884c\u7684\u5173\u952e\u3002\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u3001\u5408\u7406\u914d\u7f6e\u73af\u5883\u3001\u79d1\u5b66\u4f7f\u7528\u5e93\u548c\u719f\u7ec3\u64cd\u4f5c\u547d\u4ee4\uff0c\u80fd\u591f\u663e\u8457\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\u548c\u9879\u76ee\u8d28\u91cf\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u542f\u52a8Python\u4ea4\u4e92\u73af\u5883\uff1f<\/strong><br \/>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u63d0\u793a\u7b26\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\u6765\u542f\u52a8\u4ea4\u4e92\u73af\u5883\u3002\u5982\u679c\u4f60\u5b89\u88c5\u4e86Anaconda\uff0c\u53ef\u4ee5\u901a\u8fc7Anaconda Prompt\u8fdb\u5165Python\u4ea4\u4e92\u73af\u5883\u3002\u5728Mac\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\u540c\u6837\u53ef\u4ee5\u542f\u52a8\u4ea4\u4e92\u73af\u5883\u3002\u786e\u4fdd\u5df2\u7ecf\u6b63\u786e\u5b89\u88c5Python\uff0c\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684PATH\u53d8\u91cf\u4e2d\u3002<\/p>\n<p><strong>\u5728Python\u4ea4\u4e92\u73af\u5883\u4e2d\u53ef\u4ee5\u6267\u884c\u54ea\u4e9b\u64cd\u4f5c\uff1f<\/strong><br \/>Python\u4ea4\u4e92\u73af\u5883\u5141\u8bb8\u7528\u6237\u5b9e\u65f6\u8f93\u5165Python\u4ee3\u7801\u5e76\u7acb\u5373\u67e5\u770b\u7ed3\u679c\u3002\u7528\u6237\u53ef\u4ee5\u6267\u884c\u7b80\u5355\u7684\u6570\u5b66\u8fd0\u7b97\u3001\u5b9a\u4e49\u53d8\u91cf\u3001\u7f16\u5199\u51fd\u6570\u4ee5\u53ca\u6d4b\u8bd5\u4ee3\u7801\u7247\u6bb5\u3002\u8fd9\u79cd\u5373\u65f6\u53cd\u9988\u673a\u5236\u975e\u5e38\u9002\u5408\u5b66\u4e60\u548c\u8c03\u8bd5\u4ee3\u7801\uff0c\u5e2e\u52a9\u7528\u6237\u5feb\u901f\u7406\u89e3Python\u7684\u8bed\u6cd5\u548c\u529f\u80fd\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u4ea4\u4e92\u73af\u5883\u4e2d\u5b89\u88c5\u548c\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\uff1f<\/strong><br \/>\u5728Python\u4ea4\u4e92\u73af\u5883\u4e2d\uff0c\u65e0\u6cd5\u76f4\u63a5\u901a\u8fc7<code>pip<\/code>\u547d\u4ee4\u5b89\u88c5\u5e93\u3002\u9700\u8981\u5148\u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u4f7f\u7528<code>pip install &lt;\u5e93\u540d&gt;<\/code>\u547d\u4ee4\u5b89\u88c5\u6240\u9700\u7684\u7b2c\u4e09\u65b9\u5e93\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5728\u4ea4\u4e92\u73af\u5883\u4e2d\u901a\u8fc7<code>import &lt;\u5e93\u540d&gt;<\/code>\u6765\u4f7f\u7528\u8fd9\u4e9b\u5e93\uff0c\u5145\u5206\u5229\u7528\u5b83\u4eec\u63d0\u4f9b\u7684\u529f\u80fd\u548c\u6a21\u5757\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u63a8\u51faPython\u4ea4\u4e92\u73af\u5883\u7684\u5173\u952e\u6b65\u9aa4\u5305\u62ec\uff1a\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u3001\u914d\u7f6e\u73af\u5883\u3001\u5b89\u88c5\u5fc5\u8981\u7684\u5e93\u3001\u719f\u6089\u57fa\u672c\u547d\u4ee4\u548c\u64cd\u4f5c\u3002\u9009\u62e9\u5408\u9002\u7684 [&hellip;]","protected":false},"author":3,"featured_media":975025,"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\/975019"}],"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=975019"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/975019\/revisions"}],"predecessor-version":[{"id":975026,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/975019\/revisions\/975026"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/975025"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=975019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=975019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=975019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}