{"id":974650,"date":"2024-12-27T06:06:52","date_gmt":"2024-12-26T22:06:52","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/974650.html"},"modified":"2024-12-27T06:06:54","modified_gmt":"2024-12-26T22:06:54","slug":"python%e5%a6%82%e4%bd%95%e5%9c%a8cmd%e8%b0%83%e7%94%a8","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/974650.html","title":{"rendered":"python\u5982\u4f55\u5728cmd\u8c03\u7528"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24200245\/b34ab582-046d-412a-a17a-38646311e079.webp\" alt=\"python\u5982\u4f55\u5728cmd\u8c03\u7528\" \/><\/p>\n<p><p> \u4e00\u3001\u5728CMD\u4e2d\u8c03\u7528Python\u7684\u65b9\u6cd5<\/p>\n<\/p>\n<p><p>\u8981\u5728CMD\u4e2d\u8c03\u7528Python\uff0c<strong>\u786e\u4fdd\u5df2\u5b89\u88c5Python\u3001\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u4f7f\u7528Python\u547d\u4ee4<\/strong>\u3002\u786e\u4fdd\u5728\u5b89\u88c5Python\u65f6\u52fe\u9009\u4e86\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u6837\u53ef\u4ee5\u76f4\u63a5\u5728CMD\u4e2d\u4f7f\u7528Python\u547d\u4ee4\u3002\u82e5\u672a\u52fe\u9009\uff0c\u9700\u8981\u624b\u52a8\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u3002\u6253\u5f00CMD\u540e\uff0c\u8f93\u5165<code>python<\/code>\u6216<code>python --version<\/code>\u6765\u9a8c\u8bc1\u662f\u5426\u5b89\u88c5\u6210\u529f\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u786e\u4fdd\u5df2\u5b89\u88c5Python<\/strong>\uff1a\u9996\u5148\u9700\u8981\u5728\u7cfb\u7edf\u4e0a\u5b89\u88c5Python\u3002\u53ef\u4ee5\u4ecePython\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u9002\u5408\u4f60\u64cd\u4f5c\u7cfb\u7edf\u7684\u5b89\u88c5\u5305\u5e76\u8fdb\u884c\u5b89\u88c5\u3002\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u786e\u4fdd\u52fe\u9009\u4e86\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u6837\u53ef\u4ee5\u8ba9Python\u547d\u4ee4\u5728CMD\u4e2d\u5168\u5c40\u53ef\u7528\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/strong>\uff1a\u5982\u679c\u5728\u5b89\u88c5\u65f6\u672a\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u6216\u8005\u60f3\u624b\u52a8\u8bbe\u7f6e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u53f3\u952e\u5355\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u6211\u7684\u7535\u8111\u201d\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\u3002<\/li>\n<li>\u5728\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u3002<\/li>\n<li>\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u90e8\u5206\uff0c\u627e\u5230\u201cPath\u201d\u53d8\u91cf\u5e76\u9009\u62e9\u201c\u7f16\u8f91\u201d\u3002<\/li>\n<li>\u5728\u201c\u7f16\u8f91\u73af\u5883\u53d8\u91cf\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u65b0\u5efa\u201d\uff0c\u7136\u540e\u8f93\u5165Python\u5b89\u88c5\u76ee\u5f55\u7684\u8def\u5f84\uff08\u4f8b\u5982\uff1a<code>C:\\Python39<\/code>\uff0c\u89c6\u7248\u672c\u800c\u5b9a\uff09\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u4fdd\u5b58\u66f4\u6539\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528Python\u547d\u4ee4<\/strong>\uff1a\u6253\u5f00CMD\uff0c\u8f93\u5165<code>python<\/code>\u6216<code>python --version<\/code>\u6765\u9a8c\u8bc1Python\u662f\u5426\u5b89\u88c5\u6210\u529f\u3002\u5982\u679c\u6b63\u786e\u5b89\u88c5\u5e76\u8bbe\u7f6e\u4e86\u73af\u5883\u53d8\u91cf\uff0c\u8f93\u5165<code>python<\/code>\u5c06\u542f\u52a8Python\u7684\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u3002\u4f60\u53ef\u4ee5\u5728\u5176\u4e2d\u8f93\u5165Python\u4ee3\u7801\u8fdb\u884c\u6d4b\u8bd5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u5b89\u88c5\u4e0e\u914d\u7f6ePython<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u4e0e\u914d\u7f6ePython\u662f\u4f7f\u7528Python\u8fdb\u884c\u5f00\u53d1\u7684\u7b2c\u4e00\u6b65\u3002\u786e\u4fdd\u5b89\u88c5\u6b63\u786e\u5e76\u914d\u7f6e\u597d\u73af\u5883\u53d8\u91cf\uff0c\u53ef\u4ee5\u4f7f\u540e\u7eed\u7684\u5f00\u53d1\u8fc7\u7a0b\u66f4\u52a0\u987a\u7545\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4e0b\u8f7d\u5e76\u5b89\u88c5Python<\/strong>\uff1a\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684Python\u5b89\u88c5\u5305\u3002\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u9009\u62e9\u201cCustomize installation\u201d\u6765\u9009\u62e9\u5b89\u88c5\u8def\u5f84\u4ee5\u53ca\u9644\u52a0\u7ec4\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u52fe\u9009\u73af\u5883\u53d8\u91cf\u9009\u9879<\/strong>\uff1a\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u786e\u4fdd\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\u3002\u8fd9\u5c06\u81ea\u52a8\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u4f7f\u5f97Python\u547d\u4ee4\u5728\u4efb\u4f55\u8def\u5f84\u4e0b\u90fd\u53ef\u4ee5\u88ab\u8bc6\u522b\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00CMD\uff0c\u8f93\u5165<code>python --version<\/code>\u6765\u68c0\u67e5\u662f\u5426\u5b89\u88c5\u6210\u529f\u3002\u5982\u679c\u663e\u793aPython\u7248\u672c\u53f7\uff0c\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u5728CMD\u4e2d\u8fd0\u884cPython\u811a\u672c<\/p>\n<\/p>\n<p><p>\u8fd0\u884cPython\u811a\u672c\u662fPython\u5e94\u7528\u7684\u57fa\u7840\u6b65\u9aa4\uff0c\u901a\u8fc7CMD\u53ef\u4ee5\u5feb\u901f\u6267\u884cPython\u811a\u672c\u5e76\u67e5\u770b\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u51c6\u5907Python\u811a\u672c<\/strong>\uff1a\u5728\u6587\u672c\u7f16\u8f91\u5668\u4e2d\u7f16\u5199Python\u4ee3\u7801\uff0c\u5e76\u4fdd\u5b58\u4e3a<code>.py<\/code>\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>hello.py<\/code>\u7684\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u8f93\u5165\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>\u4f7f\u7528CMD\u8fd0\u884c\u811a\u672c<\/strong>\uff1a\u6253\u5f00CMD\uff0c\u4f7f\u7528<code>cd<\/code>\u547d\u4ee4\u5bfc\u822a\u5230\u4fdd\u5b58Python\u811a\u672c\u7684\u76ee\u5f55\u3002\u4f8b\u5982\uff0c\u5982\u679c<code>hello.py<\/code>\u5728\u684c\u9762\u4e0a\uff0c\u8f93\u5165\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">cd Desktop<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u8fd0\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<\/li>\n<li>\n<p><strong>\u67e5\u770b\u8f93\u51fa<\/strong>\uff1a\u8fd0\u884c\u811a\u672c\u540e\uff0cCMD\u7a97\u53e3\u4e2d\u5e94\u663e\u793a\u201cHello, World!\u201d\u7684\u8f93\u51fa\u3002\u5982\u679c\u51fa\u73b0\u9519\u8bef\u4fe1\u606f\uff0c\u8bf7\u68c0\u67e5\u811a\u672c\u8def\u5f84\u548c\u4ee3\u7801\u662f\u5426\u6b63\u786e\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u5904\u7406\u5e38\u89c1\u95ee\u9898<\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528CMD\u8c03\u7528Python\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\uff0c\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u53ef\u4ee5\u5feb\u901f\u89e3\u51b3\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u547d\u4ee4\u672a\u8bc6\u522b<\/strong>\uff1a\u5982\u679c\u5728CMD\u4e2d\u8f93\u5165<code>python<\/code>\u65f6\u51fa\u73b0\u201c\u547d\u4ee4\u672a\u88ab\u8bc6\u522b\u201d\u7684\u9519\u8bef\uff0c\u68c0\u67e5Python\u662f\u5426\u6b63\u786e\u5b89\u88c5\uff0c\u5e76\u786e\u8ba4\u73af\u5883\u53d8\u91cf\u4e2d\u5305\u542bPython\u8def\u5f84\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7248\u672c\u51b2\u7a81<\/strong>\uff1a\u5982\u679c\u7cfb\u7edf\u4e2d\u5b89\u88c5\u4e86\u591a\u4e2a\u7248\u672c\u7684Python\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u7248\u672c\u51b2\u7a81\u3002\u53ef\u4ee5\u901a\u8fc7\u6307\u5b9a\u5b8c\u6574\u8def\u5f84\u6765\u8fd0\u884c\u7279\u5b9a\u7248\u672c\u7684Python\uff0c\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">C:\\Python39\\python.exe hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u811a\u672c\u8def\u5f84\u9519\u8bef<\/strong>\uff1a\u786e\u4fdd\u5728CMD\u4e2d\u5bfc\u822a\u5230\u811a\u672c\u6240\u5728\u7684\u76ee\u5f55\uff0c\u6216\u8005\u5728\u8fd0\u884c\u811a\u672c\u65f6\u63d0\u4f9b\u5b8c\u6574\u8def\u5f84\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python C:\\Users\\YourName\\Desktop\\hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u4f7f\u7528Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668<\/p>\n<\/p>\n<p><p>Python\u7684\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u63d0\u4f9b\u4e86\u4e00\u4e2a\u65b9\u4fbf\u7684\u73af\u5883\u6765\u6d4b\u8bd5\u548c\u8fd0\u884cPython\u4ee3\u7801\uff0c\u7279\u522b\u9002\u5408\u4e8e\u8c03\u8bd5\u548c\u5b66\u4e60\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u542f\u52a8\u89e3\u91ca\u5668<\/strong>\uff1a\u5728CMD\u4e2d\u8f93\u5165<code>python<\/code>\u5e76\u6309\u4e0b\u56de\u8f66\u952e\uff0c\u5c06\u542f\u52a8Python\u7684\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u3002\u4f60\u4f1a\u770b\u5230\u4e00\u4e2a\u63d0\u793a\u7b26<code>&gt;&gt;&gt;<\/code>\uff0c\u8868\u793a\u53ef\u4ee5\u8f93\u5165Python\u4ee3\u7801\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6267\u884c\u4ee3\u7801<\/strong>\uff1a\u5728\u63d0\u793a\u7b26\u4e0b\u76f4\u63a5\u8f93\u5165Python\u4ee3\u7801\u5e76\u6309\u4e0b\u56de\u8f66\uff0c\u5373\u53ef\u770b\u5230\u5373\u65f6\u7684\u8f93\u51fa\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">&gt;&gt;&gt; print(&quot;Hello, Python!&quot;)<\/p>\n<p>Hello, Python!<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9000\u51fa\u89e3\u91ca\u5668<\/strong>\uff1a\u8981\u9000\u51fa\u89e3\u91ca\u5668\uff0c\u53ef\u4ee5\u8f93\u5165<code>exit()<\/code>\u6216\u6309\u4e0b<code>Ctrl + Z<\/code>\u7136\u540e\u6309\u4e0b\u56de\u8f66\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516d\u3001\u5728CMD\u4e2d\u5b89\u88c5Python\u5305<\/p>\n<\/p>\n<p><p>Python\u751f\u6001\u7cfb\u7edf\u4e30\u5bcc\u7684\u7b2c\u4e09\u65b9\u5e93\u548c\u6a21\u5757\u53ef\u4ee5\u901a\u8fc7\u5305\u7ba1\u7406\u5de5\u5177pip\u6765\u5b89\u88c5\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u68c0\u67e5pip\u5b89\u88c5<\/strong>\uff1a\u5927\u591a\u6570Python\u5b89\u88c5\u5305\u9ed8\u8ba4\u5305\u542bpip\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5pip\u662f\u5426\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Python\u5305<\/strong>\uff1a\u4f7f\u7528<code>pip install<\/code>\u547d\u4ee4\u6765\u5b89\u88c5Python\u5305\u3002\u4f8b\u5982\uff0c\u8981\u5b89\u88c5<code>requests<\/code>\u5e93\uff0c\u53ef\u4ee5\u8f93\u5165\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>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5728Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u4e2d\u8f93\u5165<code>import requests<\/code>\u6765\u9a8c\u8bc1\u5e93\u662f\u5426\u6b63\u786e\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e03\u3001\u914d\u7f6e\u865a\u62df\u73af\u5883<\/p>\n<\/p>\n<p><p>\u865a\u62df\u73af\u5883\u5141\u8bb8\u5728\u540c\u4e00\u7cfb\u7edf\u4e0a\u7ba1\u7406\u591a\u4e2aPython\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u907f\u514d\u4e0d\u540c\u9879\u76ee\u95f4\u7684\u51b2\u7a81\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong>\uff1a\u5728CMD\u4e2d\u5bfc\u822a\u5230\u9879\u76ee\u76ee\u5f55\uff0c\u7136\u540e\u8f93\u5165\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<\/li>\n<li>\n<p><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/strong>\uff1a\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">myenv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u9879\u76ee\u4f9d\u8d56<\/strong>\uff1a\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u5b89\u88c5\u9879\u76ee\u6240\u9700\u7684\u5e93\u548c\u6a21\u5757\uff0c\u8fd9\u4e9b\u5b89\u88c5\u53ea\u4f1a\u5f71\u54cd\u5f53\u524d\u865a\u62df\u73af\u5883\uff0c\u4e0d\u4f1a\u5f71\u54cd\u5168\u5c40Python\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516b\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u901a\u8fc7CMD\u8c03\u7528Python\u662fPython\u5f00\u53d1\u7684\u57fa\u7840\u6280\u80fd\u4e4b\u4e00\u3002\u901a\u8fc7\u786e\u4fddPython\u6b63\u786e\u5b89\u88c5\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u719f\u6089CMD\u547d\u4ee4\u64cd\u4f5c\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u8fd0\u884cPython\u811a\u672c\u3001\u5b89\u88c5\u4f9d\u8d56\u5305\u3001\u7ba1\u7406\u9879\u76ee\u73af\u5883\uff0c\u4ece\u800c\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002\u901a\u8fc7\u5b9e\u8df5\u8fd9\u4e9b\u64cd\u4f5c\uff0c\u4f60\u53ef\u4ee5\u719f\u7ec3\u5730\u5728CMD\u4e2d\u8c03\u7528Python\uff0c\u5f00\u542fPython\u5f00\u53d1\u4e4b\u65c5\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728CMD\u4e2d\u68c0\u67e5Python\u662f\u5426\u5df2\u5b89\u88c5\uff1f<\/strong><br \/>\u5728\u547d\u4ee4\u63d0\u793a\u7b26\uff08CMD\uff09\u4e2d\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u8f93\u5165<code>python --version<\/code>\u6216<code>python -V<\/code>\u6765\u68c0\u67e5Python\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u3002\u5982\u679cPython\u5df2\u6b63\u786e\u5b89\u88c5\uff0c\u7cfb\u7edf\u5c06\u663e\u793a\u5f53\u524d\u7684Python\u7248\u672c\u4fe1\u606f\u3002\u82e5\u672a\u5b89\u88c5\uff0c\u53ef\u80fd\u4f1a\u63d0\u793a\u201c\u672a\u627e\u5230\u547d\u4ee4\u201d\u3002<\/p>\n<p><strong>\u5728CMD\u4e2d\u5982\u4f55\u8fd0\u884c\u4e00\u4e2aPython\u811a\u672c\uff1f<\/strong><br \/>\u8981\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8fd0\u884cPython\u811a\u672c\uff0c\u60a8\u9700\u8981\u5bfc\u822a\u5230\u811a\u672c\u6240\u5728\u7684\u76ee\u5f55\u3002\u4f7f\u7528<code>cd<\/code>\u547d\u4ee4\u5207\u6362\u76ee\u5f55\uff0c\u4f8b\u5982<code>cd C:\\path\\to\\your\\script<\/code>\u3002\u63a5\u7740\uff0c\u8f93\u5165<code>python script_name.py<\/code>\u6765\u6267\u884c\u811a\u672c\uff0c\u786e\u4fdd\u5c06<code>script_name.py<\/code>\u66ff\u6362\u4e3a\u60a8\u7684\u5b9e\u9645\u811a\u672c\u6587\u4ef6\u540d\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728CMD\u4e2d\u4f7f\u7528Python\u7684\u865a\u62df\u73af\u5883\uff1f<\/strong><br \/>\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>python -m venv venv_name<\/code>\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u865a\u62df\u73af\u5883\u3002\u521b\u5efa\u540e\uff0c\u4f7f\u7528<code>venv_name\\Scripts\\activate<\/code>\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u3002\u4e00\u65e6\u6fc0\u6d3b\uff0c\u60a8\u53ef\u4ee5\u5728\u6b64\u73af\u5883\u4e2d\u5b89\u88c5\u6240\u9700\u7684\u5e93\u548c\u6a21\u5757\uff0c\u800c\u4e0d\u4f1a\u5f71\u54cd\u5168\u5c40Python\u73af\u5883\u3002\u8981\u9000\u51fa\u865a\u62df\u73af\u5883\uff0c\u53ea\u9700\u8f93\u5165<code>deactivate<\/code>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4e00\u3001\u5728CMD\u4e2d\u8c03\u7528Python\u7684\u65b9\u6cd5 \u8981\u5728CMD\u4e2d\u8c03\u7528Python\uff0c\u786e\u4fdd\u5df2\u5b89\u88c5Python\u3001\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u4f7f\u7528 [&hellip;]","protected":false},"author":3,"featured_media":974659,"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\/974650"}],"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=974650"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/974650\/revisions"}],"predecessor-version":[{"id":974663,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/974650\/revisions\/974663"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/974659"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=974650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=974650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=974650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}