{"id":1112552,"date":"2025-01-08T17:39:34","date_gmt":"2025-01-08T09:39:34","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1112552.html"},"modified":"2025-01-08T17:39:37","modified_gmt":"2025-01-08T09:39:37","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8%e6%8e%a7%e5%88%b6%e9%9d%a2%e6%9d%bf%e4%b8%8a%e9%9d%a2%e6%b7%bb%e5%8a%a0python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1112552.html","title":{"rendered":"\u5982\u4f55\u5728\u63a7\u5236\u9762\u677f\u4e0a\u9762\u6dfb\u52a0python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25074534\/72488728-1fa1-48c2-89a3-30a757c3162a.webp\" alt=\"\u5982\u4f55\u5728\u63a7\u5236\u9762\u677f\u4e0a\u9762\u6dfb\u52a0python\" \/><\/p>\n<p><p> <strong>\u5728\u63a7\u5236\u9762\u677f\u4e0a\u6dfb\u52a0Python\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u4e0b\u8f7d\u5e76\u5b89\u88c5Python\u3001\u8bbe\u7f6e\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u3001\u6d4b\u8bd5\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002<\/strong> \u5176\u4e2d\uff0c\u4e0b\u8f7d\u5e76\u5b89\u88c5Python\u662f\u6700\u5173\u952e\u7684\u4e00\u6b65\uff0c\u786e\u4fdd\u60a8\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5408\u9002\u7684\u7248\u672c\u5e76\u5b89\u88c5\u3002\u63a5\u4e0b\u6765\u9700\u8981\u8bbe\u7f6e\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528Python\u547d\u4ee4\u3002\u6700\u540e\uff0c\u901a\u8fc7\u547d\u4ee4\u884c\u6d4b\u8bd5\u5b89\u88c5\u662f\u5426\u6210\u529f\uff0c\u786e\u4fdd\u4e00\u5207\u8fd0\u884c\u6b63\u5e38\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4e0b\u8f7d\u5e76\u5b89\u88c5Python<\/p>\n<\/p>\n<p><p>\u4e0b\u8f7d\u5e76\u5b89\u88c5Python\u662f\u5c06Python\u6dfb\u52a0\u5230\u63a7\u5236\u9762\u677f\u4e2d\u7684\u7b2c\u4e00\u6b65\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9<\/strong>\uff1a\u9996\u5148\uff0c\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%E3%80%82\">https:\/\/www.python.org\/\uff09\u3002<\/a><\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9\u5408\u9002\u7684\u7248\u672c<\/strong>\uff1a\u5728\u4e0b\u8f7d\u9875\u9762\uff0c\u6839\u636e\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\uff08Windows\u3001Mac\u6216Linux\uff09\u9009\u62e9\u5408\u9002\u7684Python\u7248\u672c\u8fdb\u884c\u4e0b\u8f7d\u3002\u5bf9\u4e8e\u5927\u591a\u6570\u7528\u6237\u6765\u8bf4\uff0c\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\u662f\u6700\u4f73\u9009\u62e9\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4e0b\u8f7dPython\u5b89\u88c5\u7a0b\u5e8f<\/strong>\uff1a\u70b9\u51fb\u76f8\u5e94\u7684\u94fe\u63a5\u4e0b\u8f7dPython\u5b89\u88c5\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f<\/strong>\uff1a\u53cc\u51fb\u4e0b\u8f7d\u7684\u5b89\u88c5\u7a0b\u5e8f\u4ee5\u542f\u52a8\u5b89\u88c5\u5411\u5bfc\u3002\u5728\u5b89\u88c5\u5411\u5bfc\u4e2d\uff0c\u6709\u51e0\u4e2a\u91cd\u8981\u7684\u9009\u9879\u9700\u8981\u6ce8\u610f\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>Add Python to PATH<\/strong>\uff1a\u786e\u4fdd\u52fe\u9009\u6b64\u9009\u9879\uff0c\u8fd9\u5c06\u81ea\u52a8\u5c06Python\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/li>\n<li><strong>Customize installation<\/strong>\uff1a\u5982\u679c\u9700\u8981\uff0c\u53ef\u4ee5\u9009\u62e9\u81ea\u5b9a\u4e49\u5b89\u88c5\u8def\u5f84\u548c\u5b89\u88c5\u9009\u9879\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5b8c\u6210\u5b89\u88c5<\/strong>\uff1a\u6309\u7167\u5b89\u88c5\u5411\u5bfc\u7684\u6307\u793a\u8fdb\u884c\u64cd\u4f5c\uff0c\u76f4\u5230\u5b89\u88c5\u5b8c\u6210\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u8bbe\u7f6e\u7cfb\u7edf\u73af\u5883\u53d8\u91cf<\/p>\n<\/p>\n<p><p>\u867d\u7136\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u52fe\u9009\u4e86\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u4f46\u6709\u65f6\u53ef\u80fd\u9700\u8981\u624b\u52a8\u8bbe\u7f6e\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u6253\u5f00\u63a7\u5236\u9762\u677f<\/strong>\uff1a\u70b9\u51fb\u5f00\u59cb\u83dc\u5355\uff0c\u641c\u7d22\u5e76\u6253\u5f00\u201c\u63a7\u5236\u9762\u677f\u201d\u3002<\/li>\n<li><strong>\u8bbf\u95ee\u7cfb\u7edf\u8bbe\u7f6e<\/strong>\uff1a\u5728\u63a7\u5236\u9762\u677f\u4e2d\uff0c\u627e\u5230\u5e76\u70b9\u51fb\u201c\u7cfb\u7edf\u548c\u5b89\u5168\u201d\u9009\u9879\uff0c\u7136\u540e\u9009\u62e9\u201c\u7cfb\u7edf\u201d\u3002<\/li>\n<li><strong>\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e<\/strong>\uff1a\u5728\u7cfb\u7edf\u7a97\u53e3\u7684\u5de6\u4fa7\uff0c\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\u94fe\u63a5\u3002<\/li>\n<li><strong>\u73af\u5883\u53d8\u91cf<\/strong>\uff1a\u5728\u7cfb\u7edf\u5c5e\u6027\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u6309\u94ae\u3002<\/li>\n<li><strong>\u7f16\u8f91Path\u53d8\u91cf<\/strong>\uff1a\u5728\u73af\u5883\u53d8\u91cf\u7a97\u53e3\u4e2d\uff0c\u627e\u5230\u5e76\u9009\u62e9\u201cPath\u201d\u53d8\u91cf\uff0c\u7136\u540e\u70b9\u51fb\u201c\u7f16\u8f91\u201d\u6309\u94ae\u3002<\/li>\n<li><strong>\u6dfb\u52a0Python\u8def\u5f84<\/strong>\uff1a\u5728\u7f16\u8f91\u73af\u5883\u53d8\u91cf\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u65b0\u5efa\u201d\u6309\u94ae\uff0c\u7136\u540e\u8f93\u5165Python\u5b89\u88c5\u76ee\u5f55\u7684\u8def\u5f84\uff08\u4f8b\u5982\uff1aC:\\Python39\uff09\u3002\u540c\u65f6\uff0c\u8fd8\u9700\u8981\u6dfb\u52a0Scripts\u76ee\u5f55\u7684\u8def\u5f84\uff08\u4f8b\u5982\uff1aC:\\Python39\\Scripts\uff09\u3002<\/li>\n<li><strong>\u4fdd\u5b58\u66f4\u6539<\/strong>\uff1a\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u6309\u94ae\u4fdd\u5b58\u66f4\u6539\u3002<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u6d4b\u8bd5\u5b89\u88c5\u662f\u5426\u6210\u529f<\/p>\n<\/p>\n<p><p>\u5728\u5b8c\u6210\u5b89\u88c5\u548c\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u540e\uff0c\u9700\u8981\u6d4b\u8bd5Python\u662f\u5426\u5df2\u6210\u529f\u5b89\u88c5\u5e76\u914d\u7f6e\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26<\/strong>\uff1a\u70b9\u51fb\u5f00\u59cb\u83dc\u5355\uff0c\u641c\u7d22\u5e76\u6253\u5f00\u201c\u547d\u4ee4\u63d0\u793a\u7b26\u201d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8f93\u5165Python\u547d\u4ee4<\/strong>\uff1a\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u7a97\u53e3\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5e76\u6309\u56de\u8f66\u952e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u663e\u793a\u5df2\u5b89\u88c5\u7684Python\u7248\u672c\u53f7\u3002\u5982\u679c\u663e\u793a\u4e86\u6b63\u786e\u7684\u7248\u672c\u53f7\uff0c\u8bf4\u660ePython\u5df2\u6210\u529f\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6d4b\u8bd5pip\u547d\u4ee4<\/strong>\uff1apip\u662fPython\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u786e\u4fdd\u5176\u6b63\u5e38\u5de5\u4f5c\u975e\u5e38\u91cd\u8981\u3002\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u663e\u793a\u4e86pip\u7684\u7248\u672c\u53f7\uff0c\u8bf4\u660epip\u4e5f\u5df2\u6210\u529f\u5b89\u88c5\u5e76\u914d\u7f6e\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u53ef\u4ee5\u6210\u529f\u5730\u5728\u63a7\u5236\u9762\u677f\u4e0a\u6dfb\u52a0Python\uff0c\u5e76\u786e\u4fdd\u5176\u6b63\u5e38\u8fd0\u884c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u8fdb\u4e00\u6b65\u7684\u7ec6\u8282\u548c\u6ce8\u610f\u4e8b\u9879\uff1a<\/p>\n<\/p>\n<p><p>\u56db\u3001\u6ce8\u610f\u4e8b\u9879\u548c\u5e38\u89c1\u95ee\u9898<\/p>\n<\/p>\n<ol>\n<li><strong>\u7248\u672c\u9009\u62e9<\/strong>\uff1a\u5728\u9009\u62e9Python\u7248\u672c\u65f6\uff0c\u5efa\u8bae\u9009\u62e9\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\u3002\u7136\u800c\uff0c\u6709\u4e9b\u9879\u76ee\u53ef\u80fd\u9700\u8981\u7279\u5b9a\u7684Python\u7248\u672c\uff0c\u56e0\u6b64\u8bf7\u6839\u636e\u9879\u76ee\u9700\u6c42\u8fdb\u884c\u9009\u62e9\u3002<\/li>\n<li><strong>\u6743\u9650\u95ee\u9898<\/strong>\uff1a\u5728\u5b89\u88c5\u548c\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u65f6\uff0c\u53ef\u80fd\u9700\u8981\u7ba1\u7406\u5458\u6743\u9650\u3002\u5982\u679c\u9047\u5230\u6743\u9650\u95ee\u9898\uff0c\u8bf7\u786e\u4fdd\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u548c\u547d\u4ee4\u63d0\u793a\u7b26\u3002<\/li>\n<li><strong>\u591a\u7248\u672c\u7ba1\u7406<\/strong>\uff1a\u5982\u679c\u9700\u8981\u5728\u540c\u4e00\u53f0\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u591a\u4e2aPython\u7248\u672c\uff0c\u53ef\u4ee5\u4f7f\u7528\u5de5\u5177\u5982pyenv\uff08\u9002\u7528\u4e8eLinux\u548cmacOS\uff09\u6216pyenv-win\uff08\u9002\u7528\u4e8eWindows\uff09\u6765\u8fdb\u884c\u7248\u672c\u7ba1\u7406\u3002<\/li>\n<li><strong>IDE\u548c\u7f16\u8f91\u5668<\/strong>\uff1a\u5b89\u88c5Python\u540e\uff0c\u5efa\u8bae\u4f7f\u7528\u9002\u5408\u7684\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u6216\u6587\u672c\u7f16\u8f91\u5668\u8fdb\u884c\u5f00\u53d1\u3002\u5e38\u7528\u7684IDE\u5305\u62ecPyCharm\u3001Visual Studio Code\u7b49\u3002<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u5b89\u88c5\u5e38\u7528\u7684Python\u5305<\/p>\n<\/p>\n<p><p>\u5b89\u88c5Python\u540e\uff0c\u901a\u5e38\u9700\u8981\u5b89\u88c5\u4e00\u4e9b\u5e38\u7528\u7684Python\u5305\uff0c\u4ee5\u4fbf\u8fdb\u884c\u5404\u79cd\u5f00\u53d1\u4efb\u52a1\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u5305\u53ca\u5176\u5b89\u88c5\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u5305\u7684\u547d\u4ee4<\/strong>\uff1a\u4f7f\u7528pip\u547d\u4ee4\u53ef\u4ee5\u65b9\u4fbf\u5730\u5b89\u88c5Python\u5305\u3002\u4f8b\u5982\uff0c\u5b89\u88c5\u5e38\u7528\u7684\u5305numpy\u548cpandas\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install numpy pandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u865a\u62df\u73af\u5883<\/strong>\uff1a\u4e3a\u4e86\u907f\u514d\u5305\u7248\u672c\u51b2\u7a81\u548c\u7ba1\u7406\u4f9d\u8d56\u5173\u7cfb\uff0c\u5efa\u8bae\u4f7f\u7528\u865a\u62df\u73af\u5883\u3002\u53ef\u4ee5\u4f7f\u7528venv\u6a21\u5757\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<\/li>\n<li>\n<p><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/strong>\uff1a\u5728Windows\u4e0a\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">myenv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728macOS\u548cLinux\u4e0a\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\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<li>\n<p><strong>\u5728\u865a\u62df\u73af\u5883\u4e2d\u5b89\u88c5\u5305<\/strong>\uff1a\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u53ef\u4ee5\u5728\u5176\u4e2d\u5b89\u88c5\u6240\u9700\u7684Python\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install requests matplotlib<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516d\u3001\u4f7f\u7528Python\u5f00\u53d1\u9879\u76ee<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5e76\u914d\u7f6ePython\u540e\uff0c\u60a8\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528Python\u8fdb\u884c\u5f00\u53d1\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u5f00\u53d1\u4efb\u52a1\u53ca\u5176\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efaPython\u811a\u672c<\/strong>\uff1a\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u6216IDE\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python\u811a\u672c\u6587\u4ef6\uff08\u5982example.py\uff09\uff0c\u5e76\u7f16\u5199\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">print(&quot;Hello, Python!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884cPython\u811a\u672c<\/strong>\uff1a\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u4e2d\uff0c\u5bfc\u822a\u5230\u811a\u672c\u6240\u5728\u7684\u76ee\u5f55\uff0c\u7136\u540e\u8fd0\u884c\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python example.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528Python\u5e93<\/strong>\uff1a\u5728\u811a\u672c\u4e2d\u5bfc\u5165\u548c\u4f7f\u7528\u5df2\u5b89\u88c5\u7684Python\u5e93\u3002\u4f8b\u5982\uff0c\u4f7f\u7528numpy\u8fdb\u884c\u6570\u7ec4\u8ba1\u7b97\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>array = np.array([1, 2, 3, 4])<\/p>\n<p>print(array)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5f00\u53d1Web\u5e94\u7528<\/strong>\uff1a\u4f7f\u7528\u6846\u67b6\u5982Flask\u6216Django\u5f00\u53d1Web\u5e94\u7528\u3002\u4ee5\u4e0b\u662fFlask\u5e94\u7528\u7684\u7b80\u5355\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from flask import Flask<\/p>\n<p>app = Flask(__name__)<\/p>\n<p>@app.route(&#39;\/&#39;)<\/p>\n<p>def hello_world():<\/p>\n<p>    return &#39;Hello, Flask!&#39;<\/p>\n<p>if __name__ == &#39;__m<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>n__&#39;:<\/p>\n<p>    app.run()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6570\u636e\u5206\u6790\u548c\u53ef\u89c6\u5316<\/strong>\uff1a\u4f7f\u7528pandas\u548cmatplotlib\u8fdb\u884c\u6570\u636e\u5206\u6790\u548c\u53ef\u89c6\u5316\u3002\u4f8b\u5982\uff0c\u8bfb\u53d6CSV\u6587\u4ef6\u5e76\u7ed8\u5236\u56fe\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<p>data = pd.read_csv(&#39;data.csv&#39;)<\/p>\n<p>data.plot(kind=&#39;bar&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e03\u3001Python\u7684\u9ad8\u7ea7\u4f7f\u7528<\/p>\n<\/p>\n<p><p>\u5728\u638c\u63e1\u4e86\u57fa\u7840\u77e5\u8bc6\u540e\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u5b66\u4e60Python\u7684\u9ad8\u7ea7\u7528\u6cd5\uff0c\u4ee5\u63d0\u5347\u5f00\u53d1\u6548\u7387\u548c\u80fd\u529b\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u9ad8\u7ea7\u4e3b\u9898\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b<\/strong>\uff1a\u4e86\u89e3Python\u7684\u7c7b\u548c\u5bf9\u8c61\uff0c\u7f16\u5199\u9762\u5411\u5bf9\u8c61\u7684\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class Dog:<\/p>\n<p>    def __init__(self, name):<\/p>\n<p>        self.name = name<\/p>\n<p>    def bark(self):<\/p>\n<p>        print(f&quot;{self.name} says woof!&quot;)<\/p>\n<p>my_dog = Dog(&quot;Buddy&quot;)<\/p>\n<p>my_dog.bark()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5f02\u5e38\u5904\u7406<\/strong>\uff1a\u5b66\u4e60\u5982\u4f55\u4f7f\u7528try-except\u5757\u5904\u7406\u5f02\u5e38\uff0c\u786e\u4fdd\u7a0b\u5e8f\u7684\u5065\u58ee\u6027\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">try:<\/p>\n<p>    result = 10 \/ 0<\/p>\n<p>except ZeroDivisionError:<\/p>\n<p>    print(&quot;Cannot divide by zero!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6a21\u5757\u548c\u5305<\/strong>\uff1a\u4e86\u89e3\u5982\u4f55\u521b\u5efa\u548c\u4f7f\u7528\u6a21\u5757\u548c\u5305\uff0c\u4ee5\u7ec4\u7ec7\u548c\u91cd\u7528\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># mymodule.py<\/p>\n<p>def greet(name):<\/p>\n<p>    return f&quot;Hello, {name}!&quot;<\/p>\n<h2><strong>main.py<\/strong><\/h2>\n<p>import mymodule<\/p>\n<p>print(mymodule.greet(&quot;World&quot;))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u591a\u7ebf\u7a0b\u548c\u591a\u8fdb\u7a0b<\/strong>\uff1a\u5b66\u4e60\u5982\u4f55\u4f7f\u7528\u591a\u7ebf\u7a0b\u548c\u591a\u8fdb\u7a0b\u6765\u63d0\u9ad8\u7a0b\u5e8f\u7684\u6027\u80fd\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import threading<\/p>\n<p>def print_numbers():<\/p>\n<p>    for i in range(5):<\/p>\n<p>        print(i)<\/p>\n<p>thread = threading.Thread(target=print_numbers)<\/p>\n<p>thread.start()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7f51\u7edc\u7f16\u7a0b<\/strong>\uff1a\u4f7f\u7528Python\u8fdb\u884c\u7f51\u7edc\u7f16\u7a0b\uff0c\u7f16\u5199\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import socket<\/p>\n<p>server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<\/p>\n<p>server_socket.bind((&#39;localhost&#39;, 8080))<\/p>\n<p>server_socket.listen()<\/p>\n<p>while True:<\/p>\n<p>    client_socket, address = server_socket.accept()<\/p>\n<p>    print(f&quot;Connection from {address}&quot;)<\/p>\n<p>    client_socket.send(b&quot;Hello, World!&quot;)<\/p>\n<p>    client_socket.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u5185\u5bb9\uff0c\u60a8\u53ef\u4ee5\u5168\u9762\u4e86\u89e3\u5982\u4f55\u5728\u63a7\u5236\u9762\u677f\u4e0a\u6dfb\u52a0Python\uff0c\u5e76\u5229\u7528Python\u8fdb\u884c\u5404\u7c7b\u5f00\u53d1\u4efb\u52a1\u3002\u65e0\u8bba\u662f\u521d\u5b66\u8005\u8fd8\u662f\u6709\u7ecf\u9a8c\u7684\u5f00\u53d1\u8005\uff0c\u638c\u63e1\u8fd9\u4e9b\u77e5\u8bc6\u90fd\u5c06\u6709\u52a9\u4e8e\u63d0\u5347\u60a8\u7684\u5f00\u53d1\u6280\u80fd\u548c\u6548\u7387\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Windows\u63a7\u5236\u9762\u677f\u4e2d\u627e\u5230Python\u7684\u5b89\u88c5\u9009\u9879\uff1f<\/strong><br \/>\u5728Windows\u63a7\u5236\u9762\u677f\u4e2d\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u201c\u7a0b\u5e8f\u548c\u529f\u80fd\u201d\u6765\u67e5\u770b\u5df2\u5b89\u88c5\u7684Python\u7248\u672c\u3002\u53ea\u9700\u6253\u5f00\u63a7\u5236\u9762\u677f\uff0c\u70b9\u51fb\u201c\u7a0b\u5e8f\u201d\uff0c\u7136\u540e\u9009\u62e9\u201c\u7a0b\u5e8f\u548c\u529f\u80fd\u201d\u3002\u5728\u8fd9\u91cc\uff0c\u60a8\u4f1a\u770b\u5230\u6240\u6709\u5df2\u5b89\u88c5\u7684\u7a0b\u5e8f\uff0c\u5305\u62ecPython\u3002\u5982\u679c\u672a\u5b89\u88c5\uff0c\u60a8\u53ef\u4ee5\u76f4\u63a5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<p><strong>\u5728\u63a7\u5236\u9762\u677f\u4e2d\u6dfb\u52a0Python\u540e\uff0c\u5982\u4f55\u9a8c\u8bc1\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1f<\/strong><br \/>\u6dfb\u52a0Python\u540e\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u63d0\u793a\u7b26\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\uff0c\u5982\u679c\u6210\u529f\u5b89\u88c5\uff0c\u7cfb\u7edf\u5c06\u663e\u793a\u5df2\u5b89\u88c5\u7684Python\u7248\u672c\u4fe1\u606f\u3002<\/p>\n<p><strong>\u5982\u679c\u5728\u63a7\u5236\u9762\u677f\u4e2d\u627e\u4e0d\u5230Python\uff0c\u5e94\u8be5\u5982\u4f55\u5904\u7406\uff1f<\/strong><br \/>\u5982\u679c\u60a8\u5728\u63a7\u5236\u9762\u677f\u4e2d\u627e\u4e0d\u5230Python\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\u5c1a\u672a\u5b89\u88c5\u6216\u5b89\u88c5\u8def\u5f84\u672a\u8bbe\u7f6e\u3002\u60a8\u53ef\u4ee5\u8bbf\u95eePython\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\uff0c\u5e76\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u786e\u4fdd\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f7b\u677e\u8bbf\u95eePython\u3002\u5982\u679c\u4f9d\u7136\u65e0\u6cd5\u89e3\u51b3\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u91cd\u542f\u8ba1\u7b97\u673a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728\u63a7\u5236\u9762\u677f\u4e0a\u6dfb\u52a0Python\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u4e0b\u8f7d\u5e76\u5b89\u88c5Python\u3001\u8bbe\u7f6e\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u3001\u6d4b\u8bd5\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002 \u5176\u4e2d\uff0c\u4e0b [&hellip;]","protected":false},"author":3,"featured_media":1112563,"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\/1112552"}],"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=1112552"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1112552\/revisions"}],"predecessor-version":[{"id":1112565,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1112552\/revisions\/1112565"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1112563"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1112552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1112552"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1112552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}