{"id":1007116,"date":"2024-12-27T10:50:24","date_gmt":"2024-12-27T02:50:24","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1007116.html"},"modified":"2024-12-27T10:50:29","modified_gmt":"2024-12-27T02:50:29","slug":"terminal%e4%b8%ad%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1007116.html","title":{"rendered":"terminal\u4e2d\u5982\u4f55\u4f7f\u7528python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25082945\/a8082a8b-6b28-408a-87e0-29507b606854.webp\" alt=\"terminal\u4e2d\u5982\u4f55\u4f7f\u7528python\" \/><\/p>\n<p><p> <strong>\u5728Terminal\u4e2d\u4f7f\u7528Python\uff0c\u9996\u5148\u9700\u8981\u786e\u4fdd\u5df2\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u901a\u8fc7\u547d\u4ee4\u884c\u542f\u52a8Python\u4ea4\u4e92\u6a21\u5f0f\u3001\u7f16\u5199\u5e76\u8fd0\u884cPython\u811a\u672c\u6587\u4ef6\u3002<\/strong>\u5728\u7ec8\u7aef\u4e2d\u4f7f\u7528Python\u53ef\u4ee5\u6267\u884c\u7b80\u5355\u7684Python\u547d\u4ee4\u3001\u6d4b\u8bd5\u4ee3\u7801\u7247\u6bb5\u4ee5\u53ca\u8fd0\u884c\u5b8c\u6574\u7684Python\u7a0b\u5e8f\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u5728\u7ec8\u7aef\u4e2d\u4f7f\u7528Python\u7684\u4e00\u4e9b\u8be6\u7ec6\u6b65\u9aa4\u548c\u6280\u5de7\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5b89\u88c5Python\u89e3\u91ca\u5668<\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Python\u4e4b\u524d\uff0c\u5fc5\u987b\u786e\u4fdd\u60a8\u7684\u8ba1\u7b97\u673a\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u89e3\u91ca\u5668\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5b89\u88c5Python\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u68c0\u67e5Python\u662f\u5426\u5df2\u5b89\u88c5<\/strong>\uff1a\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\uff0c\u5982\u679c\u663e\u793a\u7248\u672c\u53f7\uff0c\u8bf4\u660ePython\u5df2\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Python<\/strong>\uff1a\u5982\u679c\u672a\u5b89\u88c5Python\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>Windows<\/strong>\uff1a\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff0c\u4e0b\u8f7d\u5e76\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u3002<\/li>\n<li><strong>macOS<\/strong>\uff1a\u4f7f\u7528Homebrew\u5305\u7ba1\u7406\u5668\uff0c\u8fd0\u884c<code>brew install python3<\/code>\u3002<\/li>\n<li><strong>Linux<\/strong>\uff1a\u4f7f\u7528\u5305\u7ba1\u7406\u5668\uff0c\u5982APT\uff08Ubuntu\/Debian\uff09\uff0c\u8fd0\u884c<code>sudo apt-get install python3<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u786e\u4fdd\u5b89\u88c5\u6210\u529f\u540e\uff0c\u518d\u6b21\u68c0\u67e5Python\u7248\u672c\u4ee5\u786e\u8ba4\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u901a\u8fc7\u547d\u4ee4\u884c\u542f\u52a8Python\u4ea4\u4e92\u6a21\u5f0f<\/p>\n<\/p>\n<p><p>Python\u4ea4\u4e92\u6a21\u5f0f\u662f\u4e00\u79cd\u5feb\u901f\u6d4b\u8bd5\u4ee3\u7801\u548c\u6267\u884cPython\u547d\u4ee4\u7684\u4fbf\u6377\u65b9\u5f0f\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u8fdb\u5165Python\u4ea4\u4e92\u6a21\u5f0f\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u542f\u52a8Python\u4ea4\u4e92\u6a21\u5f0f<\/strong>\uff1a\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\uff0c\u6309\u56de\u8f66\u952e\u8fdb\u5165\u4ea4\u4e92\u6a21\u5f0f\uff0c\u60a8\u5c06\u770b\u5230Python\u7684\u547d\u4ee4\u63d0\u793a\u7b26<code>&gt;&gt;&gt;<\/code>\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6267\u884cPython\u547d\u4ee4<\/strong>\uff1a\u5728\u4ea4\u4e92\u6a21\u5f0f\u4e0b\uff0c\u53ef\u4ee5\u76f4\u63a5\u8f93\u5165Python\u4ee3\u7801\u5e76\u6309\u56de\u8f66\u952e\u6267\u884c\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">&gt;&gt;&gt; print(&quot;Hello, World!&quot;)<\/p>\n<p>Hello, World!<\/p>\n<p>&gt;&gt;&gt; 2 + 2<\/p>\n<p>4<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9000\u51fa\u4ea4\u4e92\u6a21\u5f0f<\/strong>\uff1a\u8f93\u5165<code>exit()<\/code>\u6216\u6309<code>Ctrl + D<\/code>\u9000\u51faPython\u4ea4\u4e92\u6a21\u5f0f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u7f16\u5199\u5e76\u8fd0\u884cPython\u811a\u672c\u6587\u4ef6<\/p>\n<\/p>\n<p><p>\u9664\u4e86\u5728\u4ea4\u4e92\u6a21\u5f0f\u4e2d\u6267\u884c\u547d\u4ee4\u5916\uff0c\u60a8\u8fd8\u53ef\u4ee5\u7f16\u5199Python\u811a\u672c\u6587\u4ef6\u5e76\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efaPython\u811a\u672c\u6587\u4ef6<\/strong>\uff1a\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982Vim\u3001Nano\u6216VS Code\uff09\u521b\u5efa\u4e00\u4e2aPython\u811a\u672c\u6587\u4ef6\uff0c\u6587\u4ef6\u6269\u5c55\u540d\u901a\u5e38\u4e3a<code>.py<\/code>\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>hello.py<\/code>\u7684\u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># hello.py<\/p>\n<p>print(&quot;Hello, Python!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884cPython\u811a\u672c\u6587\u4ef6<\/strong>\uff1a\u5728\u7ec8\u7aef\u4e2d\u5bfc\u822a\u5230\u811a\u672c\u6587\u4ef6\u6240\u5728\u76ee\u5f55\uff0c\u7136\u540e\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6267\u884c\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8c03\u8bd5\u548c\u4fee\u6539\u811a\u672c<\/strong>\uff1a\u5982\u679c\u9700\u8981\u4fee\u6539\u811a\u672c\uff0c\u53ef\u4ee5\u5728\u6587\u672c\u7f16\u8f91\u5668\u4e2d\u8fdb\u884c\u66f4\u6539\uff0c\u7136\u540e\u91cd\u65b0\u8fd0\u884c\u811a\u672c\u4ee5\u67e5\u770b\u66f4\u6539\u6548\u679c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406Python\u9879\u76ee<\/p>\n<\/p>\n<p><p>\u5728\u5f00\u53d1Python\u9879\u76ee\u65f6\uff0c\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u6709\u6548\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56\u548c\u5305\u7248\u672c\uff0c\u907f\u514d\u4e0e\u5168\u5c40\u73af\u5883\u7684\u51b2\u7a81\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u521b\u5efa\u548c\u4f7f\u7528Python\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong>\uff1a\u5728\u9879\u76ee\u76ee\u5f55\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e0a\u8ff0\u547d\u4ee4\u5c06\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>myenv<\/code>\u7684\u865a\u62df\u73af\u5883\u6587\u4ef6\u5939\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>Windows<\/strong>\uff1a\u8fd0\u884c<code>myenv\\Scripts\\activate<\/code><\/li>\n<li><strong>macOS\/Linux<\/strong>\uff1a\u8fd0\u884c<code>source myenv\/bin\/activate<\/code><\/li>\n<\/ul>\n<p><p>\u6fc0\u6d3b\u540e\uff0c\u60a8\u4f1a\u5728\u7ec8\u7aef\u63d0\u793a\u7b26\u524d\u770b\u5230\u865a\u62df\u73af\u5883\u540d\u79f0\uff0c\u8868\u793a\u5f53\u524d\u6b63\u5728\u4f7f\u7528\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u9879\u76ee\u4f9d\u8d56<\/strong>\uff1a\u5728\u865a\u62df\u73af\u5883\u4e2d\uff0c\u4f7f\u7528<code>pip<\/code>\u547d\u4ee4\u5b89\u88c5\u9879\u76ee\u4f9d\u8d56\u5305\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9000\u51fa\u865a\u62df\u73af\u5883<\/strong>\uff1a\u8fd0\u884c<code>deactivate<\/code>\u547d\u4ee4\u9000\u51fa\u865a\u62df\u73af\u5883\uff0c\u6062\u590d\u5230\u5168\u5c40\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u4f7f\u7528Python\u5305\u548c\u6a21\u5757<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u5305\u548c\u6a21\u5757\u662f\u7ec4\u7ec7\u548c\u91cd\u7528\u4ee3\u7801\u7684\u91cd\u8981\u65b9\u5f0f\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u5728Python\u4e2d\u4f7f\u7528\u5305\u548c\u6a21\u5757\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5bfc\u5165Python\u6a21\u5757<\/strong>\uff1a\u5728Python\u811a\u672c\u4e2d\uff0c\u4f7f\u7528<code>import<\/code>\u8bed\u53e5\u5bfc\u5165\u6a21\u5757\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>print(math.sqrt(16))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u7b2c\u4e09\u65b9\u5305<\/strong>\uff1a\u4f7f\u7528<code>pip<\/code>\u547d\u4ee4\u5b89\u88c5\u7b2c\u4e09\u65b9\u5305\u3002\u4f8b\u5982\uff0c\u5b89\u88c5<code>numpy<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u5df2\u5b89\u88c5\u7684\u5305<\/strong>\uff1a\u5728Python\u811a\u672c\u4e2d\u5bfc\u5165\u5e76\u4f7f\u7528\u5df2\u5b89\u88c5\u7684\u5305\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>array = np.array([1, 2, 3])<\/p>\n<p>print(array)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516d\u3001\u8c03\u8bd5\u548c\u4f18\u5316Python\u4ee3\u7801<\/p>\n<\/p>\n<p><p>\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u8c03\u8bd5\u548c\u4f18\u5316\u4ee3\u7801\u662f\u786e\u4fdd\u7a0b\u5e8f\u6b63\u786e\u6027\u548c\u6548\u7387\u7684\u91cd\u8981\u6b65\u9aa4\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u8c03\u8bd5\u548c\u4f18\u5316Python\u4ee3\u7801\u7684\u6280\u5de7\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528\u8c03\u8bd5\u5668<\/strong>\uff1aPython\u63d0\u4f9b\u4e86\u5185\u7f6e\u7684\u8c03\u8bd5\u5668<code>pdb<\/code>\uff0c\u53ef\u4ee5\u5e2e\u52a9\u8ddf\u8e2a\u548c\u89e3\u51b3\u4ee3\u7801\u95ee\u9898\u3002\u5728\u811a\u672c\u4e2d\u63d2\u5165\u4ee5\u4e0b\u4ee3\u7801\u4ee5\u542f\u52a8\u8c03\u8bd5\u5668\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pdb; pdb.set_trace()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u65e5\u5fd7\u8bb0\u5f55<\/strong>\uff1a\u4f7f\u7528<code>logging<\/code>\u6a21\u5757\u8bb0\u5f55\u7a0b\u5e8f\u8fd0\u884c\u72b6\u6001\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u5206\u6790\u548c\u8c03\u8bd5\u95ee\u9898\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import logging<\/p>\n<p>logging.basicConfig(level=logging.INFO)<\/p>\n<p>logging.info(&quot;This is an informational message.&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4ee3\u7801\u4f18\u5316<\/strong>\uff1a\u5206\u6790\u4ee3\u7801\u6027\u80fd\uff0c\u8bc6\u522b\u74f6\u9888\u5e76\u8fdb\u884c\u4f18\u5316\u3002\u4f7f\u7528<code>timeit<\/code>\u6a21\u5757\u6d4b\u91cf\u4ee3\u7801\u6267\u884c\u65f6\u95f4\uff0c\u4ee5\u786e\u5b9a\u6027\u80fd\u6539\u8fdb\u7684\u6548\u679c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e03\u3001\u4f7f\u7528Python\u8fdb\u884c\u6570\u636e\u5904\u7406\u548c\u5206\u6790<\/p>\n<\/p>\n<p><p>Python\u662f\u8fdb\u884c\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u7684\u5f3a\u5927\u5de5\u5177\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684Python\u6570\u636e\u5904\u7406\u5e93\u548c\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>Pandas<\/strong>\uff1a\u7528\u4e8e\u6570\u636e\u64cd\u4f5c\u548c\u5206\u6790\u7684\u6d41\u884c\u5e93\uff0c\u63d0\u4f9bDataFrame\u6570\u636e\u7ed3\u6784\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/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<\/li>\n<li>\n<p><strong>NumPy<\/strong>\uff1a\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u7684\u5e93\uff0c\u63d0\u4f9b\u652f\u6301\u591a\u7ef4\u6570\u7ec4\u548c\u77e9\u9635\u8fd0\u7b97\u7684\u529f\u80fd\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\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, 5, 6]])<\/p>\n<p>print(array.sum(axis=0))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>Matplotlib<\/strong>\uff1a\u7528\u4e8e\u6570\u636e\u53ef\u89c6\u5316\u7684\u5e93\uff0c\u652f\u6301\u521b\u5efa\u5404\u79cd\u7c7b\u578b\u7684\u56fe\u8868\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>plt.plot([1, 2, 3], [4, 5, 6])<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\u548c\u6280\u5de7\uff0c\u60a8\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u6709\u6548\u5730\u4f7f\u7528Python\u8fdb\u884c\u5f00\u53d1\u3001\u8c03\u8bd5\u548c\u6570\u636e\u5206\u6790\u3002Python\u7684\u7075\u6d3b\u6027\u548c\u5e7f\u6cdb\u7684\u5e93\u652f\u6301\u4f7f\u5176\u6210\u4e3a\u5404\u79cd\u7f16\u7a0b\u4efb\u52a1\u7684\u7406\u60f3\u9009\u62e9\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884cPython\u811a\u672c\u7684\u6b65\u9aa4\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u8981\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884cPython\u811a\u672c\uff0c\u60a8\u9700\u8981\u6253\u5f00\u7ec8\u7aef\uff0c\u5e76\u4f7f\u7528<code>cd<\/code>\u547d\u4ee4\u5bfc\u822a\u5230\u5305\u542bPython\u811a\u672c\u7684\u76ee\u5f55\u3002\u7136\u540e\uff0c\u8f93\u5165<code>python script_name.py<\/code>\uff08\u5176\u4e2d<code>script_name.py<\/code>\u662f\u60a8\u7684\u811a\u672c\u6587\u4ef6\u540d\uff09\u5e76\u6309\u56de\u8f66\u952e\u3002\u5982\u679c\u60a8\u7684\u7cfb\u7edf\u4e2d\u540c\u65f6\u5b89\u88c5\u4e86Python 2\u548cPython 3\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4f7f\u7528<code>python3 script_name.py<\/code>\u6765\u786e\u4fdd\u4f7f\u7528Python 3\u7248\u672c\u3002<\/p>\n<p><strong>\u5982\u4f55\u5b89\u88c5Python\u4ee5\u53ca\u5728\u7ec8\u7aef\u4e2d\u68c0\u67e5\u7248\u672c\uff1f<\/strong><br \/>\u5982\u679c\u5c1a\u672a\u5b89\u88c5Python\uff0c\u53ef\u4ee5\u8bbf\u95eePython\u5b98\u7f51\uff08python.org\uff09\u4e0b\u8f7d\u9002\u5408\u60a8\u64cd\u4f5c\u7cfb\u7edf\u7684\u5b89\u88c5\u5305\u5e76\u8fdb\u884c\u5b89\u88c5\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u4ee5\u68c0\u67e5\u5df2\u5b89\u88c5\u7684Python\u7248\u672c\u3002\u8fd9\u6709\u52a9\u4e8e\u786e\u8ba4Python\u662f\u5426\u5df2\u6b63\u786e\u5b89\u88c5\u5e76\u53ef\u4f9b\u4f7f\u7528\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728\u7ec8\u7aef\u4e2d\u4f7f\u7528\u865a\u62df\u73af\u5883\u6765\u7ba1\u7406Python\u9879\u76ee\uff1f<\/strong><br \/>\u4f7f\u7528\u865a\u62df\u73af\u5883\u662f\u7ba1\u7406Python\u9879\u76ee\u4f9d\u8d56\u7684\u6700\u4f73\u5b9e\u8df5\u3002\u5728\u7ec8\u7aef\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<code>python -m venv myenv<\/code>\uff08<code>myenv<\/code>\u4e3a\u60a8\u9009\u62e9\u7684\u73af\u5883\u540d\u79f0\uff09\u3002\u521b\u5efa\u540e\uff0c\u901a\u8fc7<code>source myenv\/bin\/activate<\/code>\uff08\u5728Unix\u7cfb\u7edf\u4e2d\uff09\u6216<code>myenv\\Scripts\\activate<\/code>\uff08\u5728Windows\u7cfb\u7edf\u4e2d\uff09\u6765\u6fc0\u6d3b\u8be5\u73af\u5883\u3002\u6fc0\u6d3b\u540e\uff0c\u60a8\u53ef\u4ee5\u5b89\u88c5\u9879\u76ee\u6240\u9700\u7684\u4f9d\u8d56\uff0c\u5e76\u786e\u4fdd\u5b83\u4eec\u4e0d\u4f1a\u5f71\u54cd\u5176\u4ed6\u9879\u76ee\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Terminal\u4e2d\u4f7f\u7528Python\uff0c\u9996\u5148\u9700\u8981\u786e\u4fdd\u5df2\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u901a\u8fc7\u547d\u4ee4\u884c\u542f\u52a8Python\u4ea4\u4e92\u6a21\u5f0f [&hellip;]","protected":false},"author":3,"featured_media":1007133,"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\/1007116"}],"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=1007116"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1007116\/revisions"}],"predecessor-version":[{"id":1007134,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1007116\/revisions\/1007134"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1007133"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1007116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1007116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1007116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}