{"id":1184186,"date":"2025-01-15T19:23:27","date_gmt":"2025-01-15T11:23:27","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1184186.html"},"modified":"2025-01-15T19:23:33","modified_gmt":"2025-01-15T11:23:33","slug":"%e5%a6%82%e4%bd%95%e6%89%93%e5%bc%80python%e5%91%bd%e4%bb%a4%e6%a0%8f%e5%9c%a8%e5%93%aa","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1184186.html","title":{"rendered":"\u5982\u4f55\u6253\u5f00python\u547d\u4ee4\u680f\u5728\u54ea"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25133702\/f16933a2-812b-498a-bf68-1f05b838537f.webp\" alt=\"\u5982\u4f55\u6253\u5f00python\u547d\u4ee4\u680f\u5728\u54ea\" \/><\/p>\n<p><p> <strong>\u8981\u6253\u5f00Python\u547d\u4ee4\u680f\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u3001IDLE\u3001\u6216\u8005\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u4e2d\u7684\u7ec8\u7aef<\/strong>\u3002\u5176\u4e2d\uff0c<strong>\u4f7f\u7528\u547d\u4ee4\u884c<\/strong>\u662f\u6700\u57fa\u7840\u4e14\u901a\u7528\u7684\u65b9\u6cd5\u3002\u6253\u5f00\u547d\u4ee4\u884c\u540e\uff0c\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\uff08\u89c6\u4f60\u7684Python\u7248\u672c\u800c\u5b9a\uff09\uff0c\u5c31\u53ef\u4ee5\u8fdb\u5165Python\u4ea4\u4e92\u6a21\u5f0f\u3002\u5728Windows\u4e0a\uff0c\u53ef\u4ee5\u901a\u8fc7\u201c\u5f00\u59cb\u201d\u83dc\u5355\u627e\u5230\u547d\u4ee4\u63d0\u793a\u7b26\uff08cmd\uff09\u6216PowerShell\uff1b\u5728macOS\u548cLinux\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528\u7ec8\u7aef\u5e94\u7528\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528\u547d\u4ee4\u884c<\/h3>\n<\/p>\n<p><h4>1\u3001Windows\u7cfb\u7edf<\/h4>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u6253\u5f00Python\u547d\u4ee4\u680f\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528\u547d\u4ee4\u63d0\u793a\u7b26\uff08cmd\uff09<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6309\u4e0b<code>Win + R<\/code>\uff0c\u8f93\u5165<code>cmd<\/code>\u5e76\u6309\u4e0bEnter\u952e\uff0c\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u3002<\/li>\n<li>\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u7a97\u53e3\u4e2d\uff0c\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\uff0c\u7136\u540e\u6309\u4e0bEnter\u952e\u3002\u5982\u679cPython\u5df2\u7ecf\u6b63\u786e\u5b89\u88c5\u5e76\u914d\u7f6e\u4e86\u73af\u5883\u53d8\u91cf\uff0c\u8fd9\u5c06\u542f\u52a8Python\u89e3\u91ca\u5668\uff0c\u8fdb\u5165Python\u4ea4\u4e92\u6a21\u5f0f\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528PowerShell<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6309\u4e0b<code>Win + R<\/code>\uff0c\u8f93\u5165<code>powershell<\/code>\u5e76\u6309\u4e0bEnter\u952e\uff0c\u6253\u5f00PowerShell\u3002<\/li>\n<li>\u540c\u6837\u5730\uff0c\u5728PowerShell\u7a97\u53e3\u4e2d\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\uff0c\u7136\u540e\u6309\u4e0bEnter\u952e\uff0c\u8fdb\u5165Python\u4ea4\u4e92\u6a21\u5f0f\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h4>2\u3001macOS\u7cfb\u7edf<\/h4>\n<\/p>\n<p><p>\u5728macOS\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u6253\u5f00Python\u547d\u4ee4\u680f\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u201c\u7ec8\u7aef\u201d\u5e94\u7528\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u901a\u8fc7\u70b9\u51fb\u201cLaunchpad\u201d\u56fe\u6807\uff0c\u7136\u540e\u641c\u7d22\u201c\u7ec8\u7aef\u201d\u627e\u5230\u5e76\u6253\u5f00\u3002<\/li>\n<li>\u5728\u7ec8\u7aef\u7a97\u53e3\u4e2d\uff0c\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\uff0c\u7136\u540e\u6309\u4e0bEnter\u952e\uff0c\u8fdb\u5165Python\u4ea4\u4e92\u6a21\u5f0f\u3002<\/li>\n<\/ol>\n<p><h4>3\u3001Linux\u7cfb\u7edf<\/h4>\n<\/p>\n<p><p>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u6253\u5f00Python\u547d\u4ee4\u680f\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u201c\u7ec8\u7aef\u201d\u5e94\u7528\u7a0b\u5e8f\uff0c\u901a\u5e38\u53ef\u4ee5\u901a\u8fc7\u684c\u9762\u73af\u5883\u7684\u5e94\u7528\u7a0b\u5e8f\u83dc\u5355\u627e\u5230\u7ec8\u7aef\u3002<\/li>\n<li>\u5728\u7ec8\u7aef\u7a97\u53e3\u4e2d\uff0c\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\uff0c\u7136\u540e\u6309\u4e0bEnter\u952e\uff0c\u8fdb\u5165Python\u4ea4\u4e92\u6a21\u5f0f\u3002<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u4f7f\u7528IDLE<\/h3>\n<\/p>\n<p><p>IDLE\uff08Integrated Development and Learning Environment\uff09\u662fPython\u81ea\u5e26\u7684\u4e00\u4e2a\u7b80\u5355\u7684IDE\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u56fe\u5f62\u5316\u754c\u9762\uff0c\u53ef\u4ee5\u7528\u4e8e\u7f16\u5199\u548c\u6267\u884cPython\u4ee3\u7801\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u548c\u542f\u52a8IDLE<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u201c\u5f00\u59cb\u201d\u83dc\u5355\u627e\u5230IDLE\uff0c\u901a\u5e38\u5728\u201cPython\u201d\u6587\u4ef6\u5939\u4e2d\u3002<\/li>\n<li>\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u5982\u679c\u5b89\u88c5\u4e86Python\uff0c\u901a\u5e38\u4f1a\u81ea\u5e26IDLE\uff0c\u53ef\u4ee5\u901a\u8fc7\u7ec8\u7aef\u8f93\u5165<code>idle<\/code>\u6765\u542f\u52a8\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528IDLE<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u542f\u52a8IDLE\u540e\uff0c\u4f1a\u770b\u5230\u4e00\u4e2aPython Shell\u7a97\u53e3\uff0c\u8fd9\u5c31\u662fPython\u547d\u4ee4\u680f\u3002\u5728\u8fd9\u91cc\u53ef\u4ee5\u76f4\u63a5\u8f93\u5165Python\u4ee3\u7801\u5e76\u6267\u884c\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u4f7f\u7528IDE\u4e2d\u7684\u7ec8\u7aef<\/h3>\n<\/p>\n<p><p>\u8bb8\u591a\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u63d0\u4f9b\u4e86\u5185\u7f6e\u7684\u7ec8\u7aef\uff0c\u65b9\u4fbf\u5f00\u53d1\u8005\u5728\u7f16\u5199\u4ee3\u7801\u7684\u540c\u65f6\u6267\u884cPython\u547d\u4ee4\u3002<\/p>\n<\/p>\n<p><h4>1\u3001PyCharm<\/h4>\n<\/p>\n<p><p>PyCharm\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684Python IDE\uff0c\u63d0\u4f9b\u4e86\u5185\u7f6e\u7ec8\u7aef\u3002<\/p>\n<\/p>\n<ol>\n<li>\u542f\u52a8PyCharm\u5e76\u6253\u5f00\u4e00\u4e2a\u9879\u76ee\u3002<\/li>\n<li>\u5728\u754c\u9762\u5e95\u90e8\uff0c\u70b9\u51fb\u201cTerminal\u201d\u6807\u7b7e\uff0c\u6253\u5f00\u7ec8\u7aef\u7a97\u53e3\u3002<\/li>\n<li>\u5728\u7ec8\u7aef\u7a97\u53e3\u4e2d\uff0c\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\uff0c\u7136\u540e\u6309\u4e0bEnter\u952e\uff0c\u8fdb\u5165Python\u4ea4\u4e92\u6a21\u5f0f\u3002<\/li>\n<\/ol>\n<p><h4>2\u3001VSCode<\/h4>\n<\/p>\n<p><p>Visual Studio Code\uff08VSCode\uff09\u662f\u53e6\u4e00\u4e2a\u6d41\u884c\u7684\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\uff0c\u5305\u62ecPython\u3002<\/p>\n<\/p>\n<ol>\n<li>\u542f\u52a8VSCode\u5e76\u6253\u5f00\u4e00\u4e2a\u9879\u76ee\u3002<\/li>\n<li>\u70b9\u51fb\u754c\u9762\u5de6\u4fa7\u7684\u201c\u7ec8\u7aef\u201d\u83dc\u5355\uff0c\u7136\u540e\u9009\u62e9\u201c\u65b0\u5efa\u7ec8\u7aef\u201d\u3002<\/li>\n<li>\u5728\u65b0\u6253\u5f00\u7684\u7ec8\u7aef\u7a97\u53e3\u4e2d\uff0c\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\uff0c\u7136\u540e\u6309\u4e0bEnter\u952e\uff0c\u8fdb\u5165Python\u4ea4\u4e92\u6a21\u5f0f\u3002<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u4f7f\u7528Jupyter Notebook<\/h3>\n<\/p>\n<p><p>Jupyter Notebook\u662f\u4e00\u79cd\u4ea4\u4e92\u5f0f\u7684\u8ba1\u7b97\u73af\u5883\uff0c\u5141\u8bb8\u7528\u6237\u521b\u5efa\u548c\u5206\u4eab\u5305\u542b\u4ee3\u7801\u3001\u65b9\u7a0b\u3001\u53ef\u89c6\u5316\u548c\u6587\u672c\u7684\u6587\u6863\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Jupyter Notebook<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u5982\u679c\u6ca1\u6709\u5b89\u88c5Jupyter Notebook\uff0c\u53ef\u4ee5\u901a\u8fc7pip\u5b89\u88c5\uff1a<code>pip install notebook<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u542f\u52a8Jupyter Notebook<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\uff0c\u8f93\u5165<code>jupyter notebook<\/code>\uff0c\u7136\u540e\u6309\u4e0bEnter\u952e\u3002Jupyter Notebook\u4f1a\u5728\u9ed8\u8ba4\u6d4f\u89c8\u5668\u4e2d\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u6807\u7b7e\u9875\uff0c\u663e\u793a\u4e00\u4e2a\u57fa\u4e8eWeb\u7684\u754c\u9762\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u521b\u5efa\u548c\u4f7f\u7528Notebook<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u5728Jupyter Notebook\u754c\u9762\u4e2d\uff0c\u53ef\u4ee5\u521b\u5efa\u65b0\u7684Notebook\uff0c\u5e76\u5728\u5176\u4e2d\u7f16\u5199\u548c\u6267\u884cPython\u4ee3\u7801\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u4f7f\u7528\u5728\u7ebfPython\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u4e0d\u65b9\u4fbf\u5728\u672c\u5730\u5b89\u88c5Python\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u5728\u7ebfPython\u89e3\u91ca\u5668\u8fdb\u884cPython\u7f16\u7a0b\u548c\u6d4b\u8bd5\u3002<\/p>\n<\/p>\n<p><h4>1\u3001Repl.it<\/h4>\n<\/p>\n<p><p>Repl.it\u662f\u4e00\u4e2a\u6d41\u884c\u7684\u5728\u7ebf\u7f16\u7a0b\u5e73\u53f0\uff0c\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\uff0c\u5305\u62ecPython\u3002<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00Repl.it\u7f51\u7ad9\uff08<a href=\"https:\/\/repl.it\/%EF%BC%89%E3%80%82\">https:\/\/repl.it\/\uff09\u3002<\/a><\/li>\n<li>\u767b\u5f55\u6216\u6ce8\u518c\u8d26\u53f7\uff0c\u7136\u540e\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python repl\u3002<\/li>\n<li>\u5728\u6d4f\u89c8\u5668\u4e2d\u76f4\u63a5\u7f16\u5199\u548c\u8fd0\u884cPython\u4ee3\u7801\u3002<\/li>\n<\/ol>\n<p><h4>2\u3001PythonAnywhere<\/h4>\n<\/p>\n<p><p>PythonAnywhere\u662f\u53e6\u4e00\u4e2a\u5728\u7ebfPython\u7f16\u7a0b\u5e73\u53f0\uff0c\u63d0\u4f9b\u4e86\u514d\u8d39\u7684Python\u7f16\u7a0b\u73af\u5883\u3002<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00PythonAnywhere\u7f51\u7ad9\uff08<a href=\"https:\/\/www.pythonanywhere.com\/%EF%BC%89%E3%80%82\">https:\/\/www.pythonanywhere.com\/\uff09\u3002<\/a><\/li>\n<li>\u767b\u5f55\u6216\u6ce8\u518c\u8d26\u53f7\uff0c\u7136\u540e\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python\u6587\u4ef6\u6216Notebook\u3002<\/li>\n<li>\u5728\u6d4f\u89c8\u5668\u4e2d\u76f4\u63a5\u7f16\u5199\u548c\u8fd0\u884cPython\u4ee3\u7801\u3002<\/li>\n<\/ol>\n<p><h3>\u516d\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\uff0c\u5c3d\u7ba1\u5df2\u7ecf\u5b89\u88c5\u4e86Python\uff0c\u4f46\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\u65f6\uff0c\u7cfb\u7edf\u53ef\u80fd\u63d0\u793a\u627e\u4e0d\u5230Python\u3002\u8fd9\u901a\u5e38\u662f\u56e0\u4e3a\u6ca1\u6709\u6b63\u786e\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<\/p>\n<p><h4>1\u3001Windows\u7cfb\u7edf<\/h4>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u201c\u63a7\u5236\u9762\u677f\u201d\uff0c\u9009\u62e9\u201c\u7cfb\u7edf\u548c\u5b89\u5168\u201d\uff0c\u7136\u540e\u9009\u62e9\u201c\u7cfb\u7edf\u201d\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\uff0c\u5728\u5f39\u51fa\u7684\u7a97\u53e3\u4e2d\u9009\u62e9\u201c\u73af\u5883\u53d8\u91cf\u201d\u3002<\/li>\n<li>\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u90e8\u5206\uff0c\u627e\u5230\u5e76\u7f16\u8f91\u201cPath\u201d\u53d8\u91cf\uff0c\u6dfb\u52a0Python\u5b89\u88c5\u76ee\u5f55\u548cScripts\u76ee\u5f55\u3002\u4f8b\u5982\uff1a<code>C:\\Python39<\/code>\u548c<code>C:\\Python39\\Scripts\\<\/code>\u3002<\/li>\n<\/ol>\n<p><h4>2\u3001macOS\u548cLinux\u7cfb\u7edf<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91<code>.bashrc<\/code>\u6216<code>.bash_profile<\/code>\u6587\u4ef6\u6765\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165<code>nano ~\/.bashrc<\/code>\u6216<code>nano ~\/.bash_profile<\/code>\u3002<\/li>\n<li>\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff0c\u4fdd\u5b58\u5e76\u9000\u51fa\uff1a\n<pre><code class=\"language-sh\">export PATH=&quot;\/usr\/local\/bin\/python3:$PATH&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u8f93\u5165<code>source ~\/.bashrc<\/code>\u6216<code>source ~\/.bash_profile<\/code>\uff0c\u4f7f\u4fee\u6539\u751f\u6548\u3002<\/li>\n<\/ol>\n<p><h3>\u4e03\u3001\u5b89\u88c5Python<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u5728\u5c1d\u8bd5\u6253\u5f00Python\u547d\u4ee4\u680f\u65f6\uff0c\u53d1\u73b0\u7cfb\u7edf\u4e2d\u6ca1\u6709\u5b89\u88c5Python\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u5b89\u88c5Python\u3002<\/p>\n<\/p>\n<p><h4>1\u3001Windows\u7cfb\u7edf<\/h4>\n<\/p>\n<ol>\n<li>\u6253\u5f00Python\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%EF%BC%8C%E4%B8%8B%E8%BD%BD%E9%80%82%E7%94%A8%E4%BA%8EWindows%E7%9A%84%E5%AE%89%E8%A3%85%E7%A8%8B%E5%BA%8F%E3%80%82\">https:\/\/www.python.org\/\uff09\uff0c\u4e0b\u8f7d\u9002\u7528\u4e8eWindows\u7684\u5b89\u88c5\u7a0b\u5e8f\u3002<\/a><\/li>\n<li>\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\uff0c\u6309\u7167\u63d0\u793a\u8fdb\u884c\u5b89\u88c5\u3002\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u8bb0\u5f97\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u4ee5\u4fbf\u81ea\u52a8\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002<\/li>\n<\/ol>\n<p><h4>2\u3001macOS\u7cfb\u7edf<\/h4>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5b89\u88c5Homebrew\uff08\u5982\u679c\u5c1a\u672a\u5b89\u88c5\uff09\uff1a\n<pre><code class=\"language-sh\">\/bin\/bash -c &quot;$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/HEAD\/install.sh)&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u4f7f\u7528Homebrew\u5b89\u88c5Python\uff1a\n<pre><code class=\"language-sh\">brew install python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h4>3\u3001Linux\u7cfb\u7edf<\/h4>\n<\/p>\n<ol>\n<li>\n<p>\u6253\u5f00\u7ec8\u7aef\uff0c\u6839\u636eLinux\u53d1\u884c\u7248\u7684\u4e0d\u540c\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Python\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p>Debian\/Ubuntu\u7cfb\u7edf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">sudo apt update<\/p>\n<p>sudo apt install python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>Fedora\u7cfb\u7edf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">sudo dnf install python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>Arch Linux\u7cfb\u7edf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">sudo pacman -S python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u516b\u3001\u9a8c\u8bc1Python\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u9a8c\u8bc1Python\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u3002<\/li>\n<li>\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\uff0c\u67e5\u770bPython\u7248\u672c\u4fe1\u606f\u3002\u5982\u679c\u663e\u793a\u51fa\u6b63\u786e\u7684Python\u7248\u672c\u53f7\uff0c\u8bf4\u660ePython\u5b89\u88c5\u6210\u529f\u3002<\/li>\n<\/ol>\n<p><h3>\u4e5d\u3001\u4f7f\u7528Python\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u901a\u5e38\u4f1a\u4f7f\u7528Python\u865a\u62df\u73af\u5883\u6765\u9694\u79bb\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\u5e93\uff0c\u907f\u514d\u51b2\u7a81\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u521b\u5efa\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\uff0c\u5bfc\u822a\u5230\u9879\u76ee\u76ee\u5f55\u3002<\/li>\n<li>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\uff1a\n<pre><code class=\"language-sh\">python -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p>\u5176\u4e2d<code>myenv<\/code>\u662f\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\uff0c\u53ef\u4ee5\u6839\u636e\u9700\u8981\u4fee\u6539\u3002<\/li>\n<\/p>\n<\/ol>\n<p><h4>2\u3001\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<ol>\n<li>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a\n<pre><code class=\"language-sh\">myenv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a\n<pre><code class=\"language-sh\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h4>3\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u547d\u4ee4\u884c\u63d0\u793a\u7b26\u4f1a\u663e\u793a\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\u3002\u6b64\u65f6\uff0c\u53ef\u4ee5\u5728\u865a\u62df\u73af\u5883\u4e2d\u5b89\u88c5\u4f9d\u8d56\u5e93\uff0c\u5e76\u4f7f\u7528Python\u547d\u4ee4\u680f\u8fdb\u884c\u5f00\u53d1\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u9000\u51fa\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u5b8c\u6210\u5f00\u53d1\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u9000\u51fa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">deactivate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u5341\u3001\u4f7f\u7528Python\u5305\u7ba1\u7406\u5de5\u5177<\/h3>\n<\/p>\n<p><p>\u5728Python\u5f00\u53d1\u4e2d\uff0c\u901a\u5e38\u9700\u8981\u4f7f\u7528\u5404\u79cd\u7b2c\u4e09\u65b9\u5e93\u548c\u5305\u3002\u53ef\u4ee5\u901a\u8fc7Python\u5305\u7ba1\u7406\u5de5\u5177pip\u6765\u5b89\u88c5\u548c\u7ba1\u7406\u8fd9\u4e9b\u5e93\u548c\u5305\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u5b89\u88c5pip<\/h4>\n<\/p>\n<p><p>\u901a\u5e38\u60c5\u51b5\u4e0b\uff0cPython\u5b89\u88c5\u5305\u4e2d\u5df2\u7ecf\u5305\u542b\u4e86pip\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5pip\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u5728Windows\u7cfb\u7edf\u4e2d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">python -m ensurepip --default-pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">sudo apt-get install python3-pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><h4>2\u3001\u4f7f\u7528pip\u5b89\u88c5\u5e93\u548c\u5305<\/h4>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u3002<\/li>\n<li>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5b89\u88c5\u6240\u9700\u7684\u5e93\u6216\u5305\uff1a\n<pre><code class=\"language-sh\">pip install package_name<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p>\u5176\u4e2d<code>package_name<\/code>\u662f\u8981\u5b89\u88c5\u7684\u5e93\u6216\u5305\u7684\u540d\u79f0\u3002<\/li>\n<\/p>\n<\/ol>\n<p><h4>3\u3001\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u5e93\u548c\u5305<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u5e93\u548c\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">pip list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u5341\u4e00\u3001\u4f7f\u7528Python\u7f16\u5199\u548c\u6267\u884c\u811a\u672c<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u5728\u547d\u4ee4\u680f\u4e2d\u4ea4\u4e92\u5f0f\u5730\u8f93\u5165\u548c\u6267\u884cPython\u4ee3\u7801\u5916\uff0c\u8fd8\u53ef\u4ee5\u7f16\u5199Python\u811a\u672c\u5e76\u6267\u884c\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u7f16\u5199Python\u811a\u672c<\/h4>\n<\/p>\n<ol>\n<li>\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982Notepad++\u3001Sublime Text\u3001VSCode\u7b49\uff09\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6587\u4ef6\uff0c\u6587\u4ef6\u6269\u5c55\u540d\u4e3a<code>.py<\/code>\u3002<\/li>\n<li>\u5728\u6587\u4ef6\u4e2d\u7f16\u5199Python\u4ee3\u7801\uff0c\u5e76\u4fdd\u5b58\u6587\u4ef6\u3002<\/li>\n<\/ol>\n<p><h4>2\u3001\u6267\u884cPython\u811a\u672c<\/h4>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\uff0c\u5bfc\u822a\u5230Python\u811a\u672c\u6240\u5728\u7684\u76ee\u5f55\u3002<\/li>\n<li>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u6267\u884cPython\u811a\u672c\uff1a\n<pre><code class=\"language-sh\">python script_name.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p>\u5176\u4e2d<code>script_name.py<\/code>\u662fPython\u811a\u672c\u7684\u6587\u4ef6\u540d\u3002<\/li>\n<\/p>\n<\/ol>\n<p><h3>\u5341\u4e8c\u3001Python\u547d\u4ee4\u680f\u5e38\u89c1\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>\u5728Python\u547d\u4ee4\u680f\u4e2d\uff0c\u53ef\u4ee5\u6267\u884c\u5404\u79cdPython\u4ee3\u7801\uff0c\u4e0b\u9762\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u64cd\u4f5c\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u6253\u5370\u8f93\u51fa<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>print()<\/code>\u51fd\u6570\u6253\u5370\u8f93\u51fa\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">print(&quot;Hello, World!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u53d8\u91cf\u8d4b\u503c\u548c\u8fd0\u7b97<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u5b9a\u4e49\u53d8\u91cf\u5e76\u8fdb\u884c\u8fd0\u7b97\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">a = 10<\/p>\n<p>b = 20<\/p>\n<p>c = a + b<\/p>\n<p>print(c)  # \u8f93\u51fa30<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3\u3001\u5b9a\u4e49\u51fd\u6570<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u5b9a\u4e49\u548c\u8c03\u7528\u51fd\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def greet(name):<\/p>\n<p>    return &quot;Hello, &quot; + name<\/p>\n<p>print(greet(&quot;Alice&quot;))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4\u3001\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u8fdb\u884c\u903b\u8f91\u5224\u65ad\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">x = 10<\/p>\n<p>if x &gt; 5:<\/p>\n<p>    print(&quot;x is greater than 5&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(&quot;x is not greater than 5&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>5\u3001\u4f7f\u7528\u5faa\u73af\u8bed\u53e5<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528\u5faa\u73af\u8bed\u53e5\u8fdb\u884c\u91cd\u590d\u64cd\u4f5c\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<p><h3>\u5341\u4e09\u3001\u8c03\u8bd5Python\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u5728\u7f16\u5199\u548c\u6267\u884cPython\u4ee3\u7801\u65f6\uff0c\u8c03\u8bd5\u662f\u4e00\u4e2a\u91cd\u8981\u73af\u8282\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u8fdb\u884c\u8c03\u8bd5\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528print\u8bed\u53e5<\/h4>\n<\/p>\n<p><p>\u5728\u4ee3\u7801\u4e2d\u63d2\u5165<code>print<\/code>\u8bed\u53e5\uff0c\u8f93\u51fa\u53d8\u91cf\u503c\u548c\u72b6\u6001\u4fe1\u606f\uff0c\u5e2e\u52a9\u5b9a\u4f4d\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">x = 10<\/p>\n<p>print(&quot;x =&quot;, x)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528\u65ad\u70b9\u8c03\u8bd5<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528IDE\uff08\u5982PyCharm\u3001VSCode\uff09\u63d0\u4f9b\u7684\u65ad\u70b9\u8c03\u8bd5\u529f\u80fd\uff0c\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u8bbe\u7f6e\u65ad\u70b9\uff0c\u9010\u884c\u6267\u884c\u4ee3\u7801\uff0c\u67e5\u770b\u53d8\u91cf\u503c\u548c\u72b6\u6001\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u4f7f\u7528pdb\u8c03\u8bd5\u5668<\/h4>\n<\/p>\n<p><p>Python\u81ea\u5e26\u7684pdb\u8c03\u8bd5\u5668\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u8fdb\u884c\u8c03\u8bd5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pdb<\/p>\n<p>pdb.set_trace()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u9700\u8981\u8c03\u8bd5\u7684\u4ee3\u7801\u4f4d\u7f6e\u63d2\u5165\u4e0a\u8ff0\u4ee3\u7801\uff0c\u8fd0\u884c\u811a\u672c\u540e\u4f1a\u8fdb\u5165\u8c03\u8bd5\u6a21\u5f0f\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u56db\u3001\u4f7f\u7528Python\u8fdb\u884c\u6570\u636e\u5904\u7406<\/h3>\n<\/p>\n<p><p>Python\u5728\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u9886\u57df\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\uff0c\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u5e93\u548c\u5de5\u5177\u8fdb\u884c\u6570\u636e\u5904\u7406\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528NumPy<\/h4>\n<\/p>\n<p><p>NumPy\u662f\u4e00\u4e2a\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u7684\u5e93\uff0c\u63d0\u4f9b\u4e86\u591a\u7ef4\u6570\u7ec4\u5bf9\u8c61\u548c\u5404\u79cd\u64cd\u4f5c\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>a = np.array([1, 2, 3])<\/p>\n<p>b = np.array([4, 5, 6])<\/p>\n<p>c = a + b<\/p>\n<p>print(c)  # \u8f93\u51fa[5 7 9]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528Pandas<\/h4>\n<\/p>\n<p><p>Pandas\u662f\u4e00\u4e2a\u7528\u4e8e\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u7684\u5e93\uff0c\u63d0\u4f9b\u4e86DataFrame\u6570\u636e\u7ed3\u6784\u548c\u5404\u79cd\u64cd\u4f5c\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>data = {&#39;Name&#39;: [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Charlie&#39;], &#39;Age&#39;: [25, 30, 35]}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<p>print(df)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3\u3001\u4f7f\u7528Matplotlib<\/h4>\n<\/p>\n<p><p>Matplotlib\u662f\u4e00\u4e2a\u7528\u4e8e\u6570\u636e\u53ef\u89c6\u5316\u7684\u5e93\uff0c\u53ef\u4ee5\u521b\u5efa\u5404\u79cd\u56fe\u8868\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>x = [1, 2, 3, 4, 5]<\/p>\n<p>y = [2, 4, 6, 8, 10]<\/p>\n<p>plt.plot(x, y)<\/p>\n<p>plt.xlabel(&#39;X-axis&#39;)<\/p>\n<p>plt.ylabel(&#39;Y-axis&#39;)<\/p>\n<p>plt.title(&#39;Simple Plot&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u5341\u4e94\u3001\u4f7f\u7528Python\u8fdb\u884c\u7f51\u7edc\u7f16\u7a0b<\/h3>\n<\/p>\n<p><p>Python\u5728\u7f51\u7edc\u7f16\u7a0b\u9886\u57df\u4e5f\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\uff0c\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u5e93\u8fdb\u884c\u7f51\u7edc\u901a\u4fe1\u548c\u6570\u636e\u4f20\u8f93\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528requests\u5e93<\/h4>\n<\/p>\n<p><p>requests\u662f\u4e00\u4e2a\u7528\u4e8e\u53d1\u9001HTTP\u8bf7\u6c42\u7684\u5e93\uff0c\u7b80\u5355\u6613\u7528\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>response = requests.get(&#39;https:\/\/api.github.com&#39;)<\/p>\n<p>print(response.json())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528socket\u5e93<\/h4>\n<\/p>\n<p><p>socket\u662fPython\u6807\u51c6\u5e93\u4e2d\u7684\u4e00\u4e2a\u6a21\u5757\uff0c\u7528\u4e8e\u8fdb\u884c\u4f4e\u7ea7\u522b\u7684\u7f51\u7edc\u901a\u4fe1\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import socket<\/p>\n<p>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<\/p>\n<p>s.connect((&#39;www.example.com&#39;, 80))<\/p>\n<p>s.sendall(b&#39;GET \/ HTTP\/1.1\\r\\nHost: www.example.com\\r\\n\\r\\n&#39;)<\/p>\n<p>response = s.recv(4096)<\/p>\n<p>print(response.decode())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u5341\u516d\u3001\u4f7f\u7528Python\u8fdb\u884cWeb\u5f00\u53d1<\/h3>\n<\/p>\n<p><p>Python\u5728Web\u5f00\u53d1\u9886\u57df\u4e5f\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\uff0c\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u6846\u67b6\u8fdb\u884cWeb\u5f00\u53d1\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528Flask\u6846\u67b6<\/h4>\n<\/p>\n<p><p>Flask\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684Web\u6846\u67b6\uff0c\u9002\u5408\u5feb\u901f\u5f00\u53d1Web\u5e94\u7528\u3002<\/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 home():<\/p>\n<p>    return &quot;Hello, Flask!&quot;<\/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(debug=True)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528Django\u6846\u67b6<\/h4>\n<\/p>\n<p><p>Django\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684Web\u6846\u67b6\uff0c\u9002\u5408\u5f00\u53d1\u590d\u6742\u7684Web\u5e94\u7528\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Django\u9879\u76ee\uff1a<\/p>\n<h2><strong>django-admin startproject myproject<\/strong><\/h2>\n<h2><strong>\u5728myproject\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5e94\u7528\uff1a<\/strong><\/h2>\n<h2><strong>python manage.py startapp myapp<\/strong><\/h2>\n<h2><strong>\u7f16\u8f91myapp\/views.py\u6587\u4ef6\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/strong><\/h2>\n<p>from django.http import HttpResponse<\/p>\n<p>def home(request):<\/p>\n<p>    return HttpResponse(&quot;Hello, Django!&quot;)<\/p>\n<h2><strong>\u7f16\u8f91myproject\/urls.py\u6587\u4ef6\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/strong><\/h2>\n<p>from django.contrib import admin<\/p>\n<p>from django.urls import path<\/p>\n<p>from myapp import views<\/p>\n<p>urlpatterns = [<\/p>\n<p>    path(&#39;admin\/&#39;, admin.site.urls),<\/p>\n<p>    path(&#39;&#39;, views.home),<\/p>\n<p>]<\/p>\n<h2><strong>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u542f\u52a8Django\u5f00\u53d1\u670d\u52a1\u5668\uff1a<\/strong><\/h2>\n<h2><strong>python manage.py runserver<\/strong><\/h2>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u5341\u4e03\u3001\u4f7f\u7528Python\u8fdb\u884c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a><\/h3>\n<\/p>\n<p><p>Python\u5728\u673a\u5668\u5b66\u4e60\u9886\u57df\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\uff0c\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u5e93\u548c\u5de5\u5177\u8fdb\u884c\u673a\u5668\u5b66\u4e60\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528scikit-learn\u5e93<\/h4>\n<\/p>\n<p><p>scikit-learn\u662f\u4e00\u4e2a\u7528\u4e8e\u673a\u5668\u5b66\u4e60\u7684\u5e93\uff0c\u63d0\u4f9b\u4e86\u5404\u79cd\u7b97\u6cd5\u548c\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.datasets import load_iris<\/p>\n<p>from sklearn.model_selection import train_test_split<\/p>\n<p>from sklearn.ensemble import RandomForestClassifier<\/p>\n<p>from sklearn.metrics import accuracy_score<\/p>\n<p>data = load_iris()<\/p>\n<p>X_train, X_test, y_train, y_test = train_test_split(data.data, data.target, test_size=0.2, random_state=42)<\/p>\n<p>clf = RandomForestClassifier()<\/p>\n<p>clf.fit(X_train, y_train)<\/p>\n<p>y_pred = clf.predict(X_test)<\/p>\n<p>print(&quot;Accuracy:&quot;, accuracy_score(y_test, y_pred))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528TensorFlow\u5e93<\/h4>\n<\/p>\n<p><p>TensorFlow\u662f\u4e00\u4e2a\u7528\u4e8e\u6df1\u5ea6\u5b66\u4e60\u7684\u5e93\uff0c\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684API\u548c\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import tensorflow as tf<\/p>\n<p>from tensorflow.keras import layers, models<\/p>\n<p>model = models.Sequential([<\/p>\n<p>    layers.Dense(128, activation=&#39;relu&#39;, input_shape=(784,)),<\/p>\n<p><\/code><\/pre>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Windows\u4e0a\u6253\u5f00Python\u547d\u4ee4\u884c\u754c\u9762\uff1f<\/strong><br \/>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u6253\u5f00Python\u547d\u4ee4\u884c\u754c\u9762\u3002\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u901a\u8fc7\u201c\u5f00\u59cb\u201d\u83dc\u5355\u641c\u7d22\u201ccmd\u201d\u6216\u201c\u547d\u4ee4\u63d0\u793a\u7b26\u201d\uff0c\u7136\u540e\u8f93\u5165\u201cpython\u201d\u5e76\u6309\u56de\u8f66\u952e\u3002\u5982\u679cPython\u5df2\u6b63\u786e\u5b89\u88c5\uff0c\u8fd9\u5c06\u542f\u52a8Python\u547d\u4ee4\u884c\u3002\u6b64\u5916\uff0c\u60a8\u4e5f\u53ef\u4ee5\u76f4\u63a5\u5728\u5b89\u88c5Python\u65f6\u9009\u62e9\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\uff0c\u8fd9\u6837\u5728\u4efb\u4f55\u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u90fd\u53ef\u4ee5\u76f4\u63a5\u8f93\u5165\u201cpython\u201d\u6765\u8bbf\u95ee\u3002<\/p>\n<p><strong>\u5728Mac\u4e0a\u5982\u4f55\u6253\u5f00Python\u7ec8\u7aef\uff1f<\/strong><br \/>\u5bf9\u4e8eMac\u7528\u6237\uff0c\u53ef\u4ee5\u901a\u8fc7\u201c\u7ec8\u7aef\u201d\u5e94\u7528\u7a0b\u5e8f\u6765\u8bbf\u95eePython\u3002\u60a8\u53ef\u4ee5\u5728\u201c\u5e94\u7528\u7a0b\u5e8f\u201d\u6587\u4ef6\u5939\u7684\u201c\u5b9e\u7528\u5de5\u5177\u201d\u4e2d\u627e\u5230\u201c\u7ec8\u7aef\u201d\uff0c\u6216\u8005\u901a\u8fc7\u805a\u7126\u641c\u7d22\uff08\u6309\u4e0bCommand + \u7a7a\u683c\uff09\u5e76\u8f93\u5165\u201c\u7ec8\u7aef\u201d\u6765\u5feb\u901f\u6253\u5f00\u3002\u6253\u5f00\u7ec8\u7aef\u540e\uff0c\u8f93\u5165\u201cpython3\u201d\u5e76\u6309\u56de\u8f66\uff0c\u60a8\u5c31\u53ef\u4ee5\u8fdb\u5165Python\u7684\u547d\u4ee4\u884c\u73af\u5883\u3002<\/p>\n<p><strong>\u5982\u4f55\u68c0\u67e5Python\u662f\u5426\u5df2\u5b89\u88c5\u4ee5\u53ca\u7248\u672c\uff1f<\/strong><br \/>\u8981\u68c0\u67e5\u60a8\u7684\u7cfb\u7edf\u662f\u5426\u5b89\u88c5\u4e86Python\u4ee5\u53ca\u5176\u7248\u672c\uff0c\u60a8\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u754c\u9762\u4e2d\u8f93\u5165\u201cpython &#8211;version\u201d\u6216\u201cpython3 &#8211;version\u201d\u3002\u8fd9\u5c06\u663e\u793a\u60a8\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\u3002\u5982\u679c\u672a\u5b89\u88c5\uff0c\u7cfb\u7edf\u5c06\u63d0\u793a\u60a8\u672a\u627e\u5230\u547d\u4ee4\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u60a8\u9700\u8981\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5\u6700\u65b0\u7248\u672c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u6253\u5f00Python\u547d\u4ee4\u680f\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u3001IDLE\u3001\u6216\u8005\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u4e2d\u7684\u7ec8\u7aef\u3002\u5176\u4e2d\uff0c\u4f7f\u7528\u547d\u4ee4\u884c\u662f\u6700\u57fa [&hellip;]","protected":false},"author":3,"featured_media":1184198,"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\/1184186"}],"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=1184186"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1184186\/revisions"}],"predecessor-version":[{"id":1184200,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1184186\/revisions\/1184200"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1184198"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1184186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1184186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1184186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}