{"id":1032551,"date":"2024-12-31T11:34:37","date_gmt":"2024-12-31T03:34:37","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1032551.html"},"modified":"2024-12-31T11:34:40","modified_gmt":"2024-12-31T03:34:40","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8%e5%91%bd%e4%bb%a4%e8%a1%8c%e4%b8%ad%e5%90%af%e5%8a%a8python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1032551.html","title":{"rendered":"\u5982\u4f55\u5728\u547d\u4ee4\u884c\u4e2d\u542f\u52a8python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/142e578a-6fe3-43c6-96e0-03601e01ab32.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"\u5982\u4f55\u5728\u547d\u4ee4\u884c\u4e2d\u542f\u52a8python\" \/><\/p>\n<p><p> <strong>\u5728\u547d\u4ee4\u884c\u4e2d\u542f\u52a8 Python<\/strong><\/p>\n<\/p>\n<p><p>\u8981\u5728\u547d\u4ee4\u884c\u4e2d\u542f\u52a8 Python\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u3001\u8f93\u5165 <code>python<\/code> \u6216 <code>python3<\/code>\u3001\u6309\u4e0b\u56de\u8f66\u952e\u3002\u8fd9\u4e9b\u6b65\u9aa4\u5c06\u4f7f\u4f60\u8fdb\u5165 Python \u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u3002<strong>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u3001\u8f93\u5165 <code>python<\/code> \u6216 <code>python3<\/code>\u3001\u6309\u4e0b\u56de\u8f66\u952e<\/strong>\u3002\u4ee5\u4e0b\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u6267\u884c\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u4ee5\u53ca\u4e00\u4e9b\u6709\u7528\u7684\u547d\u4ee4\u884c\u6280\u5de7\u548c\u63d0\u793a\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef<\/p>\n<\/p>\n<p><p>\u5728\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u7684\u65b9\u6cd5\u7565\u6709\u4e0d\u540c\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>Windows<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6309 <code>Win + R<\/code> \u952e\uff0c\u8f93\u5165 <code>cmd<\/code>\uff0c\u7136\u540e\u6309\u4e0b\u56de\u8f66\u952e\u3002<\/li>\n<li>\u6216\u8005\uff0c\u70b9\u51fb\u5f00\u59cb\u83dc\u5355\uff0c\u641c\u7d22\u201c\u547d\u4ee4\u63d0\u793a\u7b26\u201d\uff0c\u7136\u540e\u70b9\u51fb\u6253\u5f00\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>macOS<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528 Spotlight \u641c\u7d22\u7ec8\u7aef\uff1a\u6309 <code>Cmd + Space<\/code>\uff0c\u8f93\u5165 <code>Terminal<\/code>\uff0c\u7136\u540e\u6309\u4e0b\u56de\u8f66\u952e\u3002<\/li>\n<li>\u6216\u8005\uff0c\u6253\u5f00 Finder\uff0c\u5bfc\u822a\u5230\u201c\u5e94\u7528\u7a0b\u5e8f\u201d&gt;\u201c\u5b9e\u7528\u5de5\u5177\u201d\u6587\u4ef6\u5939\uff0c\u53cc\u51fb\u201c\u7ec8\u7aef\u201d\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>Linux<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528\u5feb\u6377\u952e <code>Ctrl + Alt + T<\/code>\u3002<\/li>\n<li>\u6216\u8005\uff0c\u4ece\u5e94\u7528\u7a0b\u5e8f\u83dc\u5355\u4e2d\u627e\u5230\u5e76\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u8f93\u5165 <code>python<\/code> \u6216 <code>python3<\/code><\/p>\n<\/p>\n<p><p>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u540e\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u4e4b\u4e00\uff0c\u7136\u540e\u6309\u4e0b\u56de\u8f66\u952e\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u8f93\u5165 <code>python<\/code>\uff0c\u5982\u679c\u4f60\u5df2\u7ecf\u8bbe\u7f6e\u4e86 Python 3.x \u4f5c\u4e3a\u9ed8\u8ba4\u7248\u672c\u3002<\/li>\n<li>\u8f93\u5165 <code>python3<\/code>\uff0c\u5982\u679c\u4f60\u6709\u591a\u4e2a Python \u7248\u672c\uff0c\u5e76\u4e14\u60f3\u660e\u786e\u6307\u5b9a\u4f7f\u7528 Python 3.x\u3002<\/li>\n<\/ul>\n<p><p>\u8fd9\u662f\u56e0\u4e3a\u8bb8\u591a\u7cfb\u7edf\u53ef\u80fd\u540c\u65f6\u5b89\u88c5\u4e86 Python 2.x \u548c Python 3.x\uff0c\u800c <code>python<\/code> \u901a\u5e38\u6307\u5411 Python 2.x\uff0c<code>python3<\/code> \u5219\u6307\u5411 Python 3.x\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u6309\u4e0b\u56de\u8f66\u952e<\/p>\n<\/p>\n<p><p>\u6309\u4e0b\u56de\u8f66\u952e\u540e\uff0c\u4f60\u5e94\u8be5\u4f1a\u770b\u5230\u7c7b\u4f3c\u4ee5\u4e0b\u7684\u8f93\u51fa\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-plaintext\">Python 3.8.5 (default, Jul 21 2020, 10:48:26)<\/p>\n<p>[GCC 9.3.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>\u8fd9\u8868\u793a\u4f60\u5df2\u7ecf\u6210\u529f\u8fdb\u5165\u4e86 Python \u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff0c\u53ef\u4ee5\u5f00\u59cb\u8f93\u5165 Python \u4ee3\u7801\u5e76\u7acb\u5373\u6267\u884c\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u9000\u51fa Python \u89e3\u91ca\u5668<\/p>\n<\/p>\n<p><p>\u8981\u9000\u51fa Python \u89e3\u91ca\u5668\u5e76\u8fd4\u56de\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\uff0c\u53ef\u4ee5\u8f93\u5165 <code>exit()<\/code> \u5e76\u6309\u4e0b\u56de\u8f66\u952e\uff0c\u6216\u8005\u6309 <code>Ctrl + D<\/code>\uff08macOS \u548c Linux\uff09\u6216 <code>Ctrl + Z<\/code> \u7136\u540e\u6309\u4e0b\u56de\u8f66\u952e\uff08Windows\uff09\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u8fd0\u884c Python \u811a\u672c<\/p>\n<\/p>\n<p><p>\u9664\u4e86\u8fdb\u5165\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff0c\u4f60\u8fd8\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c Python \u811a\u672c\u3002\u5047\u8bbe\u4f60\u6709\u4e00\u4e2a\u540d\u4e3a <code>script.py<\/code> \u7684 Python \u6587\u4ef6\uff0c\u4f60\u53ef\u4ee5\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u6267\u884c\u5b83\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-plaintext\">python script.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\uff0c\u5982\u679c\u4f60\u4f7f\u7528 <code>python3<\/code>\uff0c\u5219\u8f93\u5165\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-plaintext\">python3 script.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u7acb\u5373\u8fd0\u884c\u811a\u672c\u4e2d\u7684\u4ee3\u7801\uff0c\u5e76\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><p>\u516d\u3001\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/p>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u4ee5\u6b63\u786e\u542f\u52a8 Python\u3002\u4f8b\u5982\uff0c\u5728 Windows \u4e0a\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u5c06 Python \u5b89\u88c5\u76ee\u5f55\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684 <code>PATH<\/code> \u73af\u5883\u53d8\u91cf\u4e2d\u3002\u4ee5\u4e0b\u662f\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\u7a97\u53e3\uff1a\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u8ba1\u7b97\u673a\u201d\u56fe\u6807\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u90e8\u5206\uff0c\u627e\u5230\u5e76\u9009\u62e9 <code>Path<\/code>\uff0c\u7136\u540e\u70b9\u51fb\u201c\u7f16\u8f91\u201d\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u65b0\u5efa\u201d\uff0c\u7136\u540e\u8f93\u5165 Python \u5b89\u88c5\u76ee\u5f55\u7684\u8def\u5f84\uff08\u4f8b\u5982 <code>C:\\Python39<\/code>\uff09\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u4fdd\u5b58\u66f4\u6539\u3002<\/li>\n<\/ol>\n<p><p>\u5728 macOS \u548c Linux \u4e0a\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91 <code>~\/.bashrc<\/code> \u6216 <code>~\/.zshrc<\/code> \u6587\u4ef6\u6765\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u3002\u4f8b\u5982\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-plaintext\">export PATH=&quot;\/usr\/local\/bin\/python3:$PATH&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4fdd\u5b58\u6587\u4ef6\u5e76\u8fd0\u884c <code>source ~\/.bashrc<\/code> \u6216 <code>source ~\/.zshrc<\/code> \u4ee5\u5e94\u7528\u66f4\u6539\u3002<\/p>\n<\/p>\n<p><p>\u4e03\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883<\/p>\n<\/p>\n<p><p>\u5728\u5f00\u53d1 Python \u9879\u76ee\u65f6\uff0c\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u5e2e\u52a9\u4f60\u7ba1\u7406\u9879\u76ee\u7684\u4f9d\u8d56\u9879\u3002\u521b\u5efa\u548c\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u5b89\u88c5 <code>virtualenv<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-plaintext\">pip install virtualenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-plaintext\">virtualenv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>Windows<\/strong>\uff1a\n<pre><code class=\"language-plaintext\">myenv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li><strong>macOS \u548c Linux<\/strong>\uff1a\n<pre><code class=\"language-plaintext\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u4f60\u53ef\u4ee5\u5728\u5176\u4e2d\u5b89\u88c5\u548c\u7ba1\u7406\u9879\u76ee\u7684\u4f9d\u8d56\u9879\uff0c\u800c\u4e0d\u4f1a\u5f71\u54cd\u5168\u5c40 Python \u73af\u5883\u3002<\/p>\n<\/p>\n<p><p>\u516b\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u53c2\u6570<\/p>\n<\/p>\n<p><p>\u5728\u6267\u884c Python \u811a\u672c\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u53c2\u6570\u4f20\u9012\u989d\u5916\u7684\u4fe1\u606f\u3002\u4f8b\u5982\uff0c\u5047\u8bbe\u4f60\u6709\u4e00\u4e2a\u540d\u4e3a <code>script.py<\/code> \u7684\u811a\u672c\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>if len(sys.argv) &gt; 1:<\/p>\n<p>    print(f&quot;Hello, {sys.argv[1]}!&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(&quot;Hello, World!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c\u811a\u672c\u5e76\u4f20\u9012\u53c2\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-plaintext\">python script.py Alice<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u5c06\u662f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-plaintext\">Hello, Alice!<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4f7f\u5f97\u4f60\u7684\u811a\u672c\u66f4\u52a0\u7075\u6d3b\uff0c\u53ef\u4ee5\u6839\u636e\u8f93\u5165\u53c2\u6570\u6267\u884c\u4e0d\u540c\u7684\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><p>\u4e5d\u3001\u4f7f\u7528 IPython \u548c Jupyter Notebook<\/p>\n<\/p>\n<p><p>\u9664\u4e86\u9ed8\u8ba4\u7684 Python \u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff0c\u4f60\u8fd8\u53ef\u4ee5\u4f7f\u7528\u66f4\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u5982 IPython \u548c Jupyter Notebook\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u5b89\u88c5 IPython\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-plaintext\">pip install ipython<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u542f\u52a8 IPython\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-plaintext\">ipython<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>IPython \u63d0\u4f9b\u4e86\u66f4\u4e30\u5bcc\u7684\u4ea4\u4e92\u4f53\u9a8c\uff0c\u5305\u62ec\u8bed\u6cd5\u9ad8\u4eae\u3001\u81ea\u52a8\u8865\u5168\u548c\u9b54\u6cd5\u547d\u4ee4\u3002<\/p>\n<\/p>\n<ol start=\"3\">\n<li>\n<p>\u5b89\u88c5 Jupyter Notebook\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-plaintext\">pip install notebook<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u542f\u52a8 Jupyter Notebook\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-plaintext\">jupyter notebook<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>Jupyter Notebook \u5141\u8bb8\u4f60\u5728\u6d4f\u89c8\u5668\u4e2d\u521b\u5efa\u548c\u5171\u4eab\u5305\u542b\u4ee3\u7801\u3001\u6587\u672c\u3001\u53ef\u89c6\u5316\u548c\u516c\u5f0f\u7684\u6587\u6863\uff0c\u975e\u5e38\u9002\u5408\u6570\u636e\u79d1\u5b66\u548c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u9879\u76ee\u3002<\/p>\n<\/p>\n<p><p>\u5341\u3001\u4f7f\u7528 Python REPL<\/p>\n<\/p>\n<p><p>Python REPL\uff08Read-Eval-Print Loop\uff09\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff0c\u5141\u8bb8\u4f60\u9010\u884c\u8f93\u5165\u548c\u6267\u884c Python \u4ee3\u7801\u3002\u4f60\u53ef\u4ee5\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u4e2d\u542f\u52a8 REPL\uff0c\u901a\u8fc7\u8f93\u5165 <code>python<\/code> \u6216 <code>python3<\/code>\u3002\u5728 REPL \u4e2d\uff0c\u4f60\u53ef\u4ee5\u6267\u884c\u5404\u79cd\u64cd\u4f5c\uff0c\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6570\u5b66\u8fd0\u7b97<\/strong>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">&gt;&gt;&gt; 2 + 2<\/p>\n<p>4<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b9a\u4e49\u53d8\u91cf<\/strong>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">&gt;&gt;&gt; x = 10<\/p>\n<p>&gt;&gt;&gt; y = 20<\/p>\n<p>&gt;&gt;&gt; x + y<\/p>\n<p>30<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b9a\u4e49\u51fd\u6570<\/strong>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">&gt;&gt;&gt; def greet(name):<\/p>\n<p>...     return f&quot;Hello, {name}!&quot;<\/p>\n<p>...<\/p>\n<p>&gt;&gt;&gt; greet(&quot;Alice&quot;)<\/p>\n<p>&#39;Hello, Alice!&#39;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>REPL \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u9002\u7528\u4e8e\u5feb\u901f\u6d4b\u8bd5\u548c\u8c03\u8bd5\u4ee3\u7801\u7247\u6bb5\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u638c\u63e1\u8fd9\u4e9b\u6280\u5de7\u548c\u5de5\u5177\uff0c\u4f60\u5c06\u80fd\u591f\u5728\u547d\u4ee4\u884c\u4e2d\u9ad8\u6548\u5730\u542f\u52a8\u548c\u4f7f\u7528 Python\uff0c\u63d0\u5347\u5f00\u53d1\u6548\u7387\u3002\u65e0\u8bba\u662f\u8fd0\u884c\u7b80\u5355\u7684\u811a\u672c\u3001\u521b\u5efa\u865a\u62df\u73af\u5883\uff0c\u8fd8\u662f\u4f7f\u7528\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff0c\u547d\u4ee4\u884c\u90fd\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5f00\u53d1\u5de5\u5177\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728\u547d\u4ee4\u884c\u4e2d\u68c0\u67e5\u662f\u5426\u5df2\u5b89\u88c5Python\uff1f<\/strong><br \/>\u8981\u786e\u8ba4\u60a8\u7684\u8ba1\u7b97\u673a\u4e0a\u662f\u5426\u5b89\u88c5\u4e86Python\uff0c\u53ef\u4ee5\u6253\u5f00\u547d\u4ee4\u884c\u754c\u9762\uff08\u5728Windows\u4e0a\u662f\u547d\u4ee4\u63d0\u793a\u7b26\u6216PowerShell\uff0c\u5728Mac\u548cLinux\u4e0a\u662f\u7ec8\u7aef\uff09\u3002\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\uff0c\u7136\u540e\u6309\u4e0b\u56de\u8f66\u952e\u3002\u5982\u679cPython\u5df2\u5b89\u88c5\uff0c\u60a8\u5c06\u770b\u5230Python\u7684\u7248\u672c\u53f7\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5\uff0c\u7cfb\u7edf\u4f1a\u63d0\u793a\u60a8\u65e0\u6cd5\u627e\u5230\u8be5\u547d\u4ee4\u3002<\/p>\n<p><strong>\u5728\u547d\u4ee4\u884c\u4e2d\u542f\u52a8\u7279\u5b9a\u7248\u672c\u7684Python\u6709\u4ec0\u4e48\u65b9\u6cd5\uff1f<\/strong><br \/>\u5982\u679c\u60a8\u7684\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u4e86\u591a\u4e2a\u7248\u672c\u7684Python\uff0c\u53ef\u4ee5\u4f7f\u7528<code>python<\/code>\u6216<code>python3<\/code>\u6765\u542f\u52a8\u9ed8\u8ba4\u7248\u672c\u3002\u5982\u679c\u8981\u542f\u52a8\u7279\u5b9a\u7248\u672c\uff0c\u53ef\u4ee5\u76f4\u63a5\u8f93\u5165\u7248\u672c\u53f7\uff0c\u4f8b\u5982<code>python3.9<\/code>\u6216<code>python2.7<\/code>\uff0c\u5e76\u6309\u4e0b\u56de\u8f66\u952e\u3002\u8fd9\u5c06\u542f\u52a8\u60a8\u6307\u5b9a\u7684Python\u7248\u672c\u7684\u547d\u4ee4\u884c\u73af\u5883\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884cPython\u811a\u672c\uff1f<\/strong><br \/>\u8981\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884cPython\u811a\u672c\uff0c\u9996\u5148\u786e\u4fdd\u60a8\u5df2\u7ecf\u5bfc\u822a\u5230\u811a\u672c\u6240\u5728\u7684\u76ee\u5f55\u3002\u4f7f\u7528<code>cd<\/code>\u547d\u4ee4\u8fdb\u5165\u8be5\u76ee\u5f55\u540e\uff0c\u8f93\u5165<code>python script_name.py<\/code>\u6216<code>python3 script_name.py<\/code>\uff08\u5c06<code>script_name.py<\/code>\u66ff\u6362\u4e3a\u60a8\u7684\u811a\u672c\u6587\u4ef6\u540d\uff09\uff0c\u7136\u540e\u6309\u56de\u8f66\u952e\u3002\u60a8\u7684Python\u811a\u672c\u5c06\u5f00\u59cb\u6267\u884c\uff0c\u5e76\u5728\u547d\u4ee4\u884c\u4e2d\u663e\u793a\u8f93\u51fa\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728\u547d\u4ee4\u884c\u4e2d\u542f\u52a8 Python \u8981\u5728\u547d\u4ee4\u884c\u4e2d\u542f\u52a8 Python\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u3001\u8f93\u5165 p [&hellip;]","protected":false},"author":3,"featured_media":1032567,"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\/1032551"}],"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=1032551"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1032551\/revisions"}],"predecessor-version":[{"id":1032572,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1032551\/revisions\/1032572"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1032567"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1032551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1032551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1032551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}