{"id":1167778,"date":"2025-01-15T15:49:40","date_gmt":"2025-01-15T07:49:40","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1167778.html"},"modified":"2025-01-15T15:49:42","modified_gmt":"2025-01-15T07:49:42","slug":"python%e5%a6%82%e4%bd%95%e6%89%93%e5%bc%80%e8%a7%a3%e9%87%8a%e5%99%a8","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1167778.html","title":{"rendered":"python\u5982\u4f55\u6253\u5f00\u89e3\u91ca\u5668"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/26065219\/dd7da56a-7e6f-4579-b3e5-4c6b952b7e64.webp\" alt=\"python\u5982\u4f55\u6253\u5f00\u89e3\u91ca\u5668\" \/><\/p>\n<p><p> <strong>\u8981\u6253\u5f00Python\u89e3\u91ca\u5668\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5<\/strong>\uff0c\u5305\u62ec\u901a\u8fc7\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3001\u901a\u8fc7Jupyter Notebook\u7b49\u3002<strong>\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u901a\u8fc7\u547d\u4ee4\u884c\u6216\u7ec8\u7aef<\/strong>\u3002\u4e0b\u9762\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u6253\u5f00Python\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<p><p><strong>\u901a\u8fc7\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u6253\u5f00Python\u89e3\u91ca\u5668<\/strong>\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u6253\u5f00\u547d\u4ee4\u884c\u6216\u7ec8\u7aef<\/strong>\uff1a\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u5f00\u59cb\u83dc\u5355\u641c\u7d22\u201ccmd\u201d\u6216\u201c\u547d\u4ee4\u63d0\u793a\u7b26\u201d\u5e76\u6253\u5f00\u3002\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li><strong>\u8f93\u5165Python\u547d\u4ee4<\/strong>\uff1a\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\uff0c\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\uff0c\u7136\u540e\u6309\u56de\u8f66\u952e\u3002\u5982\u679c\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86Python\uff0c\u89e3\u91ca\u5668\u5c06\u542f\u52a8\uff0c\u5e76\u663e\u793aPython\u7684\u7248\u672c\u4fe1\u606f\u548c\u63d0\u793a\u7b26<code>&gt;&gt;&gt;<\/code>\uff0c\u8868\u793a\u53ef\u4ee5\u5f00\u59cb\u8f93\u5165Python\u4ee3\u7801\u3002<\/li>\n<\/ol>\n<p><p>\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">$ python3<\/p>\n<p>Python 3.9.7 (default, Sep  3 2021, 12:37:55)<\/p>\n<p>[GCC 8.4.0] on linux<\/p>\n<p>Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<\/p>\n<p>&gt;&gt;&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u8be6\u7ec6\u63cf\u8ff0\u901a\u8fc7\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u6253\u5f00Python\u89e3\u91ca\u5668\u7684\u6b65\u9aa4<\/strong>\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Python<\/strong>\uff1a\u5728\u4f7f\u7528Python\u89e3\u91ca\u5668\u4e4b\u524d\uff0c\u9700\u8981\u786e\u4fdd\u7cfb\u7edf\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5\uff0c\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%E9%80%82%E5%90%88%E4%BD%A0%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E7%9A%84Python%E7%89%88%E6%9C%AC%E3%80%82%E5%AE%89%E8%A3%85%E8%BF%87%E7%A8%8B%E4%B8%AD%E8%AF%B7%E7%A1%AE%E4%BF%9D%E5%8B%BE%E9%80%89%E2%80%9CAdd\">https:\/\/www.python.org\uff09\u4e0b\u8f7d\u5e76\u5b89\u88c5\u9002\u5408\u4f60\u64cd\u4f5c\u7cfb\u7edf\u7684Python\u7248\u672c\u3002\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u8bf7\u786e\u4fdd\u52fe\u9009\u201cAdd<\/a> Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u5c06\u4f7f\u5f97\u5728\u547d\u4ee4\u884c\u4e2d\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528Python\u547d\u4ee4\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u68c0\u67e5Python\u5b89\u88c5\u662f\u5426\u6210\u529f<\/strong>\uff1a\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\uff0c\u6309\u56de\u8f66\u952e\u3002\u5982\u679cPython\u5b89\u88c5\u6210\u529f\uff0c\u5c06\u663e\u793aPython\u7684\u7248\u672c\u4fe1\u606f\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">$ python3 --version<\/p>\n<p>Python 3.9.7<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u542f\u52a8Python\u89e3\u91ca\u5668<\/strong>\uff1a\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\u547d\u4ee4\u5e76\u6309\u56de\u8f66\u952e\uff0cPython\u89e3\u91ca\u5668\u5c06\u542f\u52a8\uff0c\u5e76\u663e\u793aPython\u7684\u7248\u672c\u4fe1\u606f\u548c\u63d0\u793a\u7b26<code>&gt;&gt;&gt;<\/code>\u3002\u4f60\u73b0\u5728\u53ef\u4ee5\u5f00\u59cb\u8f93\u5165\u548c\u6267\u884cPython\u4ee3\u7801\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e00\u3001\u901a\u8fc7\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u6253\u5f00Python\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9009\u62e9IDE<\/strong>\uff1a\u6709\u8bb8\u591a\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u53ef\u4ee5\u7528\u6765\u7f16\u5199\u548c\u8fd0\u884cPython\u4ee3\u7801\uff0c\u4f8b\u5982PyCharm\u3001Visual Studio Code\u3001Atom\u3001Jupyter Notebook\u7b49\u3002\u9009\u62e9\u4e00\u4e2a\u9002\u5408\u4f60\u7684IDE\u5e76\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6ePython\u73af\u5883<\/strong>\uff1a\u6253\u5f00IDE\u5e76\u914d\u7f6ePython\u89e3\u91ca\u5668\u3002\u5927\u591a\u6570IDE\u4f1a\u5728\u521d\u6b21\u542f\u52a8\u65f6\u81ea\u52a8\u68c0\u6d4b\u7cfb\u7edf\u4e2d\u7684Python\u5b89\u88c5\uff0c\u5e76\u63d0\u793a\u4f60\u8fdb\u884c\u914d\u7f6e\u3002\u5982\u679c\u6ca1\u6709\u68c0\u6d4b\u5230\uff0c\u53ef\u4ee5\u5728IDE\u7684\u8bbe\u7f6e\u6216\u504f\u597d\u4e2d\u624b\u52a8\u914d\u7f6ePython\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6253\u5f00\u7ec8\u7aef\u6216\u63a7\u5236\u53f0<\/strong>\uff1a\u5728IDE\u4e2d\u901a\u5e38\u4f1a\u6709\u5185\u7f6e\u7684\u7ec8\u7aef\u6216\u63a7\u5236\u53f0\u7a97\u53e3\uff0c\u53ef\u4ee5\u5728\u5176\u4e2d\u8f93\u5165\u548c\u6267\u884cPython\u4ee3\u7801\u3002\u4f8b\u5982\uff0c\u5728PyCharm\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u83dc\u5355\u680f\u9009\u62e9\u201cView\u201d -&gt; \u201cTool Windows\u201d -&gt; \u201cTerminal\u201d\u6765\u6253\u5f00\u7ec8\u7aef\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u542f\u52a8Python\u89e3\u91ca\u5668<\/strong>\uff1a\u5728IDE\u7684\u7ec8\u7aef\u6216\u63a7\u5236\u53f0\u4e2d\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\u547d\u4ee4\u5e76\u6309\u56de\u8f66\u952e\uff0cPython\u89e3\u91ca\u5668\u5c06\u542f\u52a8\uff0c\u5e76\u663e\u793a\u63d0\u793a\u7b26<code>&gt;&gt;&gt;<\/code>\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u901a\u8fc7Jupyter Notebook\u6253\u5f00Python\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Jupyter Notebook<\/strong>\uff1a\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u548cpip\u3002\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5Jupyter Notebook\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">$ pip install notebook<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u542f\u52a8Jupyter Notebook<\/strong>\uff1a\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u542f\u52a8Jupyter Notebook\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">$ jupyter notebook<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u521b\u5efa\u65b0\u7684Notebook<\/strong>\uff1aJupyter Notebook\u5c06\u542f\u52a8\u4e00\u4e2a\u672c\u5730\u670d\u52a1\u5668\uff0c\u5e76\u5728\u9ed8\u8ba4\u6d4f\u89c8\u5668\u4e2d\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u6807\u7b7e\u9875\u3002\u5728\u6d4f\u89c8\u5668\u4e2d\uff0c\u70b9\u51fb\u201cNew\u201d\u6309\u94ae\u5e76\u9009\u62e9\u201cPython 3\u201d\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Notebook\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8f93\u5165\u548c\u6267\u884cPython\u4ee3\u7801<\/strong>\uff1a\u5728\u65b0\u7684Notebook\u4e2d\uff0c\u53ef\u4ee5\u5728\u5355\u5143\u683c\u4e2d\u8f93\u5165Python\u4ee3\u7801\uff0c\u7136\u540e\u6309Shift+Enter\u6765\u6267\u884c\u4ee3\u7801\u5e76\u67e5\u770b\u8f93\u51fa\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u901a\u8fc7\u56fe\u5f62\u7528\u6237\u754c\u9762\uff08GUI\uff09\u6253\u5f00Python\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528IDLE<\/strong>\uff1aIDLE\u662fPython\u81ea\u5e26\u7684\u96c6\u6210\u5f00\u53d1\u73af\u5883\u3002\u5b89\u88c5Python\u65f6\u901a\u5e38\u4f1a\u540c\u65f6\u5b89\u88c5IDLE\u3002\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u5f00\u59cb\u83dc\u5355\u641c\u7d22\u201cIDLE\u201d\u5e76\u6253\u5f00\u3002\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u8f93\u5165<code>idle<\/code>\u6765\u542f\u52a8IDLE\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u5176\u4ed6GUI\u5de5\u5177<\/strong>\uff1a\u6709\u8bb8\u591a\u5176\u4ed6\u56fe\u5f62\u7528\u6237\u754c\u9762\u5de5\u5177\u53ef\u4ee5\u7528\u6765\u6253\u5f00Python\u89e3\u91ca\u5668\uff0c\u4f8b\u5982Thonny\u3001Spyder\u7b49\u3002\u8fd9\u4e9b\u5de5\u5177\u901a\u5e38\u63d0\u4f9b\u4e86\u4e00\u4e2aPython Shell\u7a97\u53e3\uff0c\u53ef\u4ee5\u5728\u5176\u4e2d\u8f93\u5165\u548c\u6267\u884cPython\u4ee3\u7801\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u901a\u8fc7\u8fdc\u7a0b\u670d\u52a1\u5668\u6216\u4e91\u5e73\u53f0\u6253\u5f00Python\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8fde\u63a5\u5230\u8fdc\u7a0b\u670d\u52a1\u5668<\/strong>\uff1a\u5982\u679c\u4f60\u9700\u8981\u5728\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u8fd0\u884cPython\u4ee3\u7801\uff0c\u53ef\u4ee5\u901a\u8fc7SSH\u8fde\u63a5\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u3002\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u8fde\u63a5\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">$ ssh username@hostname<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u542f\u52a8Python\u89e3\u91ca\u5668<\/strong>\uff1a\u8fde\u63a5\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u540e\uff0c\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\u547d\u4ee4\u5e76\u6309\u56de\u8f66\u952e\uff0cPython\u89e3\u91ca\u5668\u5c06\u542f\u52a8\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u4e91\u5e73\u53f0<\/strong>\uff1a\u6709\u8bb8\u591a\u4e91\u5e73\u53f0\u63d0\u4f9b\u4e86\u5728\u7ebf\u7684Python\u89e3\u91ca\u5668\u548c\u5f00\u53d1\u73af\u5883\uff0c\u4f8b\u5982Google Colab\u3001Microsoft Azure Notebooks\u3001IBM Watson Studio\u7b49\u3002\u6ce8\u518c\u5e76\u767b\u5f55\u8fd9\u4e9b\u5e73\u53f0\u540e\uff0c\u53ef\u4ee5\u5728\u6d4f\u89c8\u5668\u4e2d\u4f7f\u7528Python\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u6253\u5f00Python\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong>\uff1a\u5728\u9879\u76ee\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u865a\u62df\u73af\u5883\u3002\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">$ python3 -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\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u4ee5\u4f7f\u7528\u5176\u4e2d\u7684Python\u89e3\u91ca\u5668\u3002\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\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\u7cfb\u7edf\u4e2d\uff0c\u8f93\u5165\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>\u542f\u52a8Python\u89e3\u91ca\u5668<\/strong>\uff1a\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\u547d\u4ee4\u5e76\u6309\u56de\u8f66\u952e\uff0cPython\u89e3\u91ca\u5668\u5c06\u542f\u52a8\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u516d\u3001\u901a\u8fc7Docker\u5bb9\u5668\u6253\u5f00Python\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Docker<\/strong>\uff1a\u786e\u4fdd\u4f60\u7684\u7cfb\u7edf\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86Docker\u3002\u53ef\u4ee5\u4eceDocker\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.docker.com%EF%BC%89%E4%B8%8B%E8%BD%BD%E5%B9%B6%E5%AE%89%E8%A3%85Docker%E3%80%82\">https:\/\/www.docker.com\uff09\u4e0b\u8f7d\u5e76\u5b89\u88c5Docker\u3002<\/a><\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u62c9\u53d6Python\u955c\u50cf<\/strong>\uff1a\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u62c9\u53d6\u5b98\u65b9\u7684Python\u955c\u50cf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">$ docker pull python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884cPython\u5bb9\u5668<\/strong>\uff1a\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u8fd0\u884cPython\u5bb9\u5668\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">$ docker run -it python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u542f\u52a8\u4e00\u4e2aPython\u5bb9\u5668\uff0c\u5e76\u6253\u5f00Python\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e03\u3001\u901a\u8fc7\u811a\u672c\u6587\u4ef6\u8fd0\u884cPython\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efaPython\u811a\u672c\u6587\u4ef6<\/strong>\uff1a\u5728\u6587\u672c\u7f16\u8f91\u5668\u6216IDE\u4e2d\u521b\u5efa\u4e00\u4e2aPython\u811a\u672c\u6587\u4ef6\uff0c\u5e76\u7f16\u5199Python\u4ee3\u7801\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>script.py<\/code>\u7684\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u5199\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">print(&quot;Hello, world!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884cPython\u811a\u672c\u6587\u4ef6<\/strong>\uff1a\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u5bfc\u822a\u5230\u811a\u672c\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\uff0c\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u8fd0\u884cPython\u811a\u672c\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">$ python script.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u8fd0\u884c\u811a\u672c\u6587\u4ef6\uff0c\u5e76\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u516b\u3001\u901a\u8fc7\u73af\u5883\u7ba1\u7406\u5de5\u5177\u6253\u5f00Python\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528Conda<\/strong>\uff1aConda\u662f\u4e00\u4e2a\u6d41\u884c\u7684\u5305\u548c\u73af\u5883\u7ba1\u7406\u5de5\u5177\uff0c\u7279\u522b\u9002\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u79d1\u5b66\u3002\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86Anaconda\u6216Miniconda\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u521b\u5efaConda\u73af\u5883<\/strong>\uff1a\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Conda\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">$ conda create --name myenv python=3.9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6fc0\u6d3bConda\u73af\u5883<\/strong>\uff1a\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u6fc0\u6d3bConda\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">$ conda activate myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u542f\u52a8Python\u89e3\u91ca\u5668<\/strong>\uff1a\u6fc0\u6d3bConda\u73af\u5883\u540e\uff0c\u8f93\u5165<code>python<\/code>\u547d\u4ee4\u5e76\u6309\u56de\u8f66\u952e\uff0cPython\u89e3\u91ca\u5668\u5c06\u542f\u52a8\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e5d\u3001\u901a\u8fc7\u8fdc\u7a0b\u5f00\u53d1\u73af\u5883\u6253\u5f00Python\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528\u8fdc\u7a0b\u5f00\u53d1\u5de5\u5177<\/strong>\uff1a\u6709\u8bb8\u591a\u8fdc\u7a0b\u5f00\u53d1\u5de5\u5177\u53ef\u4ee5\u7528\u6765\u5728\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u7f16\u5199\u548c\u8fd0\u884cPython\u4ee3\u7801\uff0c\u4f8b\u5982Visual Studio Code Remote &#8211; SSH\u6269\u5c55\u3001PyCharm Professional\u7684\u8fdc\u7a0b\u5f00\u53d1\u529f\u80fd\u7b49\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6e\u8fdc\u7a0b\u73af\u5883<\/strong>\uff1a\u6309\u7167\u8fdc\u7a0b\u5f00\u53d1\u5de5\u5177\u7684\u6587\u6863\u914d\u7f6e\u8fdc\u7a0b\u5f00\u53d1\u73af\u5883\uff0c\u8fde\u63a5\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\uff0c\u5e76\u5728\u8fdc\u7a0b\u73af\u5883\u4e2d\u542f\u52a8Python\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u5341\u3001\u901a\u8fc7\u5728\u7ebf\u7f16\u8bd1\u5668\u6253\u5f00Python\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9009\u62e9\u5728\u7ebf\u7f16\u8bd1\u5668<\/strong>\uff1a\u6709\u8bb8\u591a\u5728\u7ebf\u7f16\u8bd1\u5668\u53ef\u4ee5\u7528\u6765\u7f16\u5199\u548c\u8fd0\u884cPython\u4ee3\u7801\uff0c\u4f8b\u5982Repl.it\u3001PythonAnywhere\u3001OnlineGDB\u7b49\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7f16\u5199\u548c\u8fd0\u884c\u4ee3\u7801<\/strong>\uff1a\u6253\u5f00\u5728\u7ebf\u7f16\u8bd1\u5668\u7684\u7f51\u7ad9\uff0c\u5728\u6d4f\u89c8\u5668\u4e2d\u7f16\u5199Python\u4ee3\u7801\uff0c\u5e76\u70b9\u51fb\u201c\u8fd0\u884c\u201d\u6309\u94ae\u6765\u6267\u884c\u4ee3\u7801\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u5341\u4e00\u3001\u901a\u8fc7Python REPL\u6253\u5f00Python\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528Python REPL<\/strong>\uff1aREPL\uff08Read-Eval-Print Loop\uff09\u662fPython\u89e3\u91ca\u5668\u7684\u4e00\u79cd\u4ea4\u4e92\u6a21\u5f0f\uff0c\u53ef\u4ee5\u7528\u6765\u8f93\u5165\u548c\u6267\u884cPython\u4ee3\u7801\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u542f\u52a8REPL<\/strong>\uff1a\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\u547d\u4ee4\u5e76\u6309\u56de\u8f66\u952e\uff0cPython REPL\u5c06\u542f\u52a8\uff0c\u5e76\u663e\u793a\u63d0\u793a\u7b26<code>&gt;&gt;&gt;<\/code>\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u5341\u4e8c\u3001\u901a\u8fc7Django\u6216Flask\u7b49\u6846\u67b6\u6253\u5f00Python\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u6846\u67b6<\/strong>\uff1a\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86Django\u3001Flask\u7b49\u6846\u67b6\u3002\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5Django\u6216Flask\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">$ pip install django<\/p>\n<p>$ pip install flask<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u542f\u52a8\u6846\u67b6\u7684\u4ea4\u4e92\u5f0fShell<\/strong>\uff1aDjango\u548cFlask\u7b49\u6846\u67b6\u63d0\u4f9b\u4e86\u4ea4\u4e92\u5f0fShell\uff0c\u53ef\u4ee5\u7528\u6765\u8f93\u5165\u548c\u6267\u884cPython\u4ee3\u7801\u3002\u4f8b\u5982\uff0c\u542f\u52a8Django\u7684\u4ea4\u4e92\u5f0fShell\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">$ python manage.py shell<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u542f\u52a8Flask\u7684\u4ea4\u4e92\u5f0fShell\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">$ flask shell<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8f93\u5165\u548c\u6267\u884c\u4ee3\u7801<\/strong>\uff1a\u5728\u4ea4\u4e92\u5f0fShell\u4e2d\uff0c\u53ef\u4ee5\u8f93\u5165\u548c\u6267\u884cPython\u4ee3\u7801\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u73af\u5883\u548c\u5de5\u5177\u4e2d\u6253\u5f00Python\u89e3\u91ca\u5668\uff0c\u7f16\u5199\u548c\u8fd0\u884cPython\u4ee3\u7801\u3002\u9009\u62e9\u9002\u5408\u4f60\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u66f4\u9ad8\u6548\u5730\u8fdb\u884cPython\u5f00\u53d1\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\u4e2d\u6253\u5f00Python\u89e3\u91ca\u5668\uff1f<\/strong><br \/>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u63d0\u793a\u7b26\u6253\u5f00Python\u89e3\u91ca\u5668\u3002\u53ea\u9700\u6309\u4e0b\u201cWin + R\u201d\u952e\uff0c\u8f93\u5165\u201ccmd\u201d\uff0c\u7136\u540e\u6309\u56de\u8f66\u3002\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\uff0c\u8f93\u5165\u201cpython\u201d\u5e76\u6309\u56de\u8f66\u5373\u53ef\u542f\u52a8\u89e3\u91ca\u5668\u3002\u5982\u679c\u5df2\u5b89\u88c5Python\uff0c\u5e76\u8bbe\u7f6e\u4e86\u73af\u5883\u53d8\u91cf\uff0c\u5c06\u4f1a\u770b\u5230Python\u63d0\u793a\u7b26\u3002\u5728macOS\u6216Linux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165\u201cpython3\u201d\u6216\u201cpython\u201d\uff0c\u89c6\u5177\u4f53\u5b89\u88c5\u800c\u5b9a\uff0c\u6309\u56de\u8f66\u540e\u540c\u6837\u53ef\u4ee5\u8fdb\u5165Python\u89e3\u91ca\u5668\u3002<\/p>\n<p><strong>\u5728Python\u89e3\u91ca\u5668\u4e2d\u53ef\u4ee5\u6267\u884c\u54ea\u4e9b\u64cd\u4f5c\uff1f<\/strong><br \/>Python\u89e3\u91ca\u5668\u4e0d\u4ec5\u53ef\u4ee5\u7528\u6765\u6267\u884c\u7b80\u5355\u7684Python\u8bed\u53e5\uff0c\u8fd8\u652f\u6301\u6d4b\u8bd5\u4ee3\u7801\u7247\u6bb5\u3001\u8c03\u8bd5\u7a0b\u5e8f\u548c\u8fdb\u884c\u5373\u65f6\u8ba1\u7b97\u3002\u7528\u6237\u53ef\u4ee5\u76f4\u63a5\u8f93\u5165\u6570\u5b66\u8fd0\u7b97\u3001\u53d8\u91cf\u8d4b\u503c\u3001\u51fd\u6570\u5b9a\u4e49\u7b49\uff0c\u770b\u5230\u5373\u65f6\u7684\u53cd\u9988\u3002\u8fd9\u4f7f\u5f97\u5b83\u975e\u5e38\u9002\u5408\u5b66\u4e60\u548c\u5b9e\u9a8c\uff0c\u4e5f\u4fbf\u4e8e\u5feb\u901f\u9a8c\u8bc1\u60f3\u6cd5\u3002<\/p>\n<p><strong>\u5982\u4f55\u9000\u51faPython\u89e3\u91ca\u5668\uff1f<\/strong><br \/>\u9000\u51faPython\u89e3\u91ca\u5668\u975e\u5e38\u7b80\u5355\u3002\u7528\u6237\u53ef\u4ee5\u8f93\u5165\u201cexit()\u201d\u6216\u4f7f\u7528\u5feb\u6377\u952e\u201cCtrl + Z\u201d\uff08Windows\uff09\u6216\u201cCtrl + D\u201d\uff08macOS\/Linux\uff09\u540e\u6309\u56de\u8f66\u5373\u53ef\u5b89\u5168\u9000\u51fa\u3002\u8fd9\u4e9b\u65b9\u6cd5\u80fd\u591f\u786e\u4fdd\u4f60\u7684\u4f1a\u8bdd\u7ed3\u675f\uff0c\u5e76\u4e14\u4e0d\u4f1a\u4e22\u5931\u4efb\u4f55\u672a\u4fdd\u5b58\u7684\u5de5\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u6253\u5f00Python\u89e3\u91ca\u5668\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec\u901a\u8fc7\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3001\u901a\u8fc7Jupyte [&hellip;]","protected":false},"author":3,"featured_media":1167779,"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\/1167778"}],"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=1167778"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1167778\/revisions"}],"predecessor-version":[{"id":1167780,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1167778\/revisions\/1167780"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1167779"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1167778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1167778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1167778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}