{"id":1132763,"date":"2025-01-08T21:00:14","date_gmt":"2025-01-08T13:00:14","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1132763.html"},"modified":"2025-01-08T21:00:17","modified_gmt":"2025-01-08T13:00:17","slug":"%e5%b7%b2%e7%bb%8f%e5%ae%89%e8%a3%85python%e5%a6%82%e4%bd%95%e4%bb%8e%e5%91%bd%e4%bb%a4%e8%a1%8c%e6%89%93%e5%bc%80%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1132763.html","title":{"rendered":"\u5df2\u7ecf\u5b89\u88c5python\u5982\u4f55\u4ece\u547d\u4ee4\u884c\u6253\u5f00\u6587\u4ef6"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25102217\/4248ec25-cd5b-4e55-be5e-513d59389fa4.webp\" alt=\"\u5df2\u7ecf\u5b89\u88c5python\u5982\u4f55\u4ece\u547d\u4ee4\u884c\u6253\u5f00\u6587\u4ef6\" \/><\/p>\n<p><p> \u4e00\u3001\u5982\u4f55\u4ece\u547d\u4ee4\u884c\u6253\u5f00Python\u6587\u4ef6<\/p>\n<\/p>\n<p><p><strong>\u8981\u4ece\u547d\u4ee4\u884c\u6253\u5f00Python\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u8f93\u5165\u547d\u4ee4\u3001\u786e\u4fdd\u6587\u4ef6\u8def\u5f84\u6b63\u786e\u3001\u4f7f\u7528Python\u89e3\u91ca\u5668\u7b49\u6b65\u9aa4\u3002<\/strong> \u9996\u5148\uff0c\u4f60\u9700\u8981\u6253\u5f00\u547d\u4ee4\u884c\u754c\u9762\uff08\u5982Windows\u7684cmd\u3001Mac\u7684\u7ec8\u7aef\u6216Linux\u7684shell\uff09\u3002\u63a5\u7740\uff0c\u5bfc\u822a\u5230\u5305\u542b\u4f60\u8981\u8fd0\u884c\u7684Python\u6587\u4ef6\u7684\u76ee\u5f55\u3002\u6700\u540e\uff0c\u4f7f\u7528Python\u89e3\u91ca\u5668\u547d\u4ee4\u6765\u8fd0\u884c\u8be5\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>python script.py<\/code>\u5373\u53ef\u8fd0\u884c\u540d\u4e3a<code>script.py<\/code>\u7684Python\u6587\u4ef6\u3002<strong>\u786e\u4fddPython\u73af\u5883\u53d8\u91cf\u5df2\u914d\u7f6e<\/strong>\u662f\u81f3\u5173\u91cd\u8981\u7684\u4e00\u6b65\uff0c\u5426\u5219\u547d\u4ee4\u884c\u65e0\u6cd5\u8bc6\u522b<code>python<\/code>\u547d\u4ee4\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u786e\u4fdd\u6587\u4ef6\u8def\u5f84\u6b63\u786e<\/h3>\n<\/p>\n<p><p>\u786e\u4fdd\u6587\u4ef6\u8def\u5f84\u6b63\u786e\u662f\u6210\u529f\u8fd0\u884cPython\u6587\u4ef6\u7684\u5173\u952e\u6b65\u9aa4\u4e4b\u4e00\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u6765\u786e\u8ba4\u6587\u4ef6\u8def\u5f84\uff1a<\/p>\n<\/p>\n<p><h4>1.1\u3001\u5bfc\u822a\u5230\u6587\u4ef6\u6240\u5728\u76ee\u5f55<\/h4>\n<\/p>\n<p><p>\u5728\u547d\u4ee4\u884c\u754c\u9762\u4e2d\uff0c\u4f7f\u7528<code>cd<\/code>\u547d\u4ee4\u5bfc\u822a\u5230\u5305\u542bPython\u6587\u4ef6\u7684\u76ee\u5f55\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u7684Python\u6587\u4ef6\u4f4d\u4e8e<code>C:\\Users\\YourName\\Documents<\/code>\u76ee\u5f55\u4e0b\uff0c\u4f60\u53ef\u4ee5\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">cd C:\\Users\\YourName\\Documents<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728Mac\u6216Linux\u7cfb\u7edf\u4e2d\uff0c\u8def\u5f84\u683c\u5f0f\u53ef\u80fd\u4f1a\u6709\u6240\u4e0d\u540c\uff0c\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">cd \/Users\/YourName\/Documents<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>1.2\u3001\u68c0\u67e5\u6587\u4ef6\u662f\u5426\u5b58\u5728<\/h4>\n<\/p>\n<p><p>\u5728\u5bfc\u822a\u5230\u76ee\u6807\u76ee\u5f55\u540e\uff0c\u4f7f\u7528<code>ls<\/code>\uff08Mac\/Linux\uff09\u6216<code>dir<\/code>\uff08Windows\uff09\u547d\u4ee4\u5217\u51fa\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\uff0c\u786e\u4fdd\u4f60\u7684Python\u6587\u4ef6\u786e\u5b9e\u5b58\u5728\u4e8e\u8be5\u76ee\u5f55\u4e2d\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">ls<\/p>\n<h2><strong>\u6216<\/strong><\/h2>\n<p>dir<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u786e\u8ba4\u6587\u4ef6\u5b58\u5728\u540e\uff0c\u4f60\u5c31\u53ef\u4ee5\u7ee7\u7eed\u4e0b\u4e00\u6b65\u4e86\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528Python\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<p><p>\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528Python\u89e3\u91ca\u5668\u6765\u8fd0\u884c\u4f60\u7684Python\u6587\u4ef6\u662f\u6700\u540e\u4e00\u6b65\u3002\u6839\u636e\u4f60\u5b89\u88c5\u7684Python\u7248\u672c\uff0c\u547d\u4ee4\u53ef\u80fd\u4f1a\u6709\u6240\u4e0d\u540c\u3002<\/p>\n<\/p>\n<p><h4>2.1\u3001\u4f7f\u7528Python 3\u89e3\u91ca\u5668<\/h4>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u5b89\u88c5\u7684\u662fPython 3.x\u7248\u672c\uff0c\u901a\u5e38\u53ef\u4ee5\u4f7f\u7528<code>python3<\/code>\u547d\u4ee4\u8fd0\u884cPython\u6587\u4ef6\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 script.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2.2\u3001\u4f7f\u7528Python 2\u89e3\u91ca\u5668<\/h4>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u5b89\u88c5\u7684\u662fPython 2.x\u7248\u672c\uff0c\u4f7f\u7528<code>python<\/code>\u547d\u4ee4\u5373\u53ef\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python script.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2.3\u3001\u4f7f\u7528\u7cfb\u7edf\u9ed8\u8ba4Python\u89e3\u91ca\u5668<\/h4>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\uff0c<code>python<\/code>\u547d\u4ee4\u53ef\u80fd\u4f1a\u6307\u5411\u7cfb\u7edf\u9ed8\u8ba4\u7684Python\u89e3\u91ca\u5668\uff0c\u53ef\u80fd\u662fPython 2\u6216Python 3\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6765\u68c0\u67e5\u7cfb\u7edf\u9ed8\u8ba4\u7684Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6839\u636e\u8f93\u51fa\u7ed3\u679c\uff0c\u9009\u62e9\u5408\u9002\u7684\u547d\u4ee4\u6765\u8fd0\u884c\u4f60\u7684Python\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u914d\u7f6ePython\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>\u914d\u7f6ePython\u73af\u5883\u53d8\u91cf\u662f\u786e\u4fdd\u547d\u4ee4\u884c\u80fd\u591f\u8bc6\u522b<code>python<\/code>\u547d\u4ee4\u7684\u5173\u952e\u6b65\u9aa4\u4e4b\u4e00\u3002\u5728\u5927\u591a\u6570\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0cPython\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u4f46\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u624b\u52a8\u914d\u7f6e\u3002<\/p>\n<\/p>\n<p><h4>3.1\u3001\u5728Windows\u4e2d\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h4>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u4f60\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u914d\u7f6ePython\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u53f3\u952e\u70b9\u51fb\u201c\u8ba1\u7b97\u673a\u201d\u6216\u201c\u6b64\u7535\u8111\u201d\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\uff0c\u7136\u540e\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\u9009\u62e9<code>Path<\/code>\u53d8\u91cf\uff0c\u70b9\u51fb\u201c\u7f16\u8f91\u201d\u3002<\/li>\n<li>\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>\uff09\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u4fdd\u5b58\u8bbe\u7f6e\u3002<\/li>\n<\/ol>\n<p><h4>3.2\u3001\u5728Mac\u6216Linux\u4e2d\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h4>\n<\/p>\n<p><p>\u5728Mac\u6216Linux\u7cfb\u7edf\u4e2d\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91<code>~\/.bash_profile<\/code>\u6216<code>~\/.bashrc<\/code>\u6587\u4ef6\u6765\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u7f16\u8f91<code>~\/.bash_profile<\/code>\u6587\u4ef6\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">nano ~\/.bash_profile<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li>\u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">export PATH=&quot;\/usr\/local\/bin\/python3:$PATH&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li>\u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6\uff0c\u7136\u540e\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u4f7f\u66f4\u6539\u751f\u6548\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">source ~\/.bash_profile<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848<\/h3>\n<\/p>\n<p><p>\u5728\u8fd0\u884cPython\u6587\u4ef6\u65f6\uff0c\u4f60\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u53ef\u80fd\u7684\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<\/p>\n<p><h4>4.1\u3001\u547d\u4ee4\u884c\u65e0\u6cd5\u8bc6\u522b<code>python<\/code>\u547d\u4ee4<\/h4>\n<\/p>\n<p><p>\u5982\u679c\u547d\u4ee4\u884c\u65e0\u6cd5\u8bc6\u522b<code>python<\/code>\u547d\u4ee4\uff0c\u53ef\u80fd\u662f\u56e0\u4e3aPython\u73af\u5883\u53d8\u91cf\u672a\u6b63\u786e\u914d\u7f6e\u3002\u4f60\u53ef\u4ee5\u6309\u7167\u4e0a\u8ff0\u6b65\u9aa4\u624b\u52a8\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<\/p>\n<p><h4>4.2\u3001\u6587\u4ef6\u8def\u5f84\u9519\u8bef<\/h4>\n<\/p>\n<p><p>\u786e\u4fdd\u4f60\u5728\u547d\u4ee4\u884c\u4e2d\u5bfc\u822a\u5230\u5305\u542bPython\u6587\u4ef6\u7684\u6b63\u786e\u76ee\u5f55\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528<code>cd<\/code>\u547d\u4ee4\u6765\u66f4\u6539\u76ee\u5f55\uff0c\u4f7f\u7528<code>ls<\/code>\u6216<code>dir<\/code>\u547d\u4ee4\u5217\u51fa\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h4>4.3\u3001Python\u7248\u672c\u95ee\u9898<\/h4>\n<\/p>\n<p><p>\u786e\u4fdd\u4f60\u4f7f\u7528\u7684Python\u89e3\u91ca\u5668\u7248\u672c\u4e0e\u6587\u4ef6\u4e2d\u7684\u4ee3\u7801\u517c\u5bb9\u3002\u5982\u679c\u4f60\u4e0d\u786e\u5b9a\u7cfb\u7edf\u4e2d\u5b89\u88c5\u4e86\u54ea\u4e9bPython\u7248\u672c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python --version<\/p>\n<p>python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u4ece\u547d\u4ee4\u884c\u4f20\u9012\u53c2\u6570\u7ed9Python\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u4ece\u547d\u4ee4\u884c\u5411Python\u6587\u4ef6\u4f20\u9012\u53c2\u6570\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528<code>sys.argv<\/code>\u6765\u83b7\u53d6\u547d\u4ee4\u884c\u53c2\u6570\u3002\u4f8b\u5982\uff0c\u5047\u8bbe\u4f60\u6709\u4e00\u4e2a\u540d\u4e3a<code>script.py<\/code>\u7684\u6587\u4ef6\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;Argument received: {sys.argv[1]}&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(&quot;No arguments received&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u4f20\u9012\u53c2\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python script.py Hello<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u5c06\u662f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">Argument received: Hello<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e03\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u5728\u5f00\u53d1Python\u9879\u76ee\u65f6\uff0c\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u5e2e\u52a9\u4f60\u9694\u79bb\u9879\u76ee\u4f9d\u8d56\uff0c\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u4f9d\u8d56\u51b2\u7a81\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528<code>virtualenv<\/code>\u6216<code>venv<\/code>\u6a21\u5757\u521b\u5efa\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<p><h4>6.1\u3001\u5b89\u88c5\u865a\u62df\u73af\u5883\u6a21\u5757<\/h4>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u5c1a\u672a\u5b89\u88c5<code>virtualenv<\/code>\u6a21\u5757\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install virtualenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>Python 3.3\u53ca\u4ee5\u4e0a\u7248\u672c\u81ea\u5e26<code>venv<\/code>\u6a21\u5757\uff0c\u56e0\u6b64\u4e0d\u9700\u8981\u989d\u5916\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h4>6.2\u3001\u521b\u5efa\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>virtualenv<\/code>\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">virtualenv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528<code>venv<\/code>\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<p><h4>6.3\u3001\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\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<p><p>\u5728Mac\u6216Linux\u7cfb\u7edf\u4e2d\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>6.4\u3001\u5728\u865a\u62df\u73af\u5883\u4e2d\u8fd0\u884cPython\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u4f60\u53ef\u4ee5\u5728\u865a\u62df\u73af\u5883\u4e2d\u8fd0\u884cPython\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>\u865a\u62df\u73af\u5883\u5e2e\u52a9\u4f60\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56\uff0c\u4f7f\u9879\u76ee\u66f4\u52a0\u6a21\u5757\u5316\u548c\u53ef\u7ef4\u62a4\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09<\/h3>\n<\/p>\n<p><p>\u867d\u7136\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884cPython\u6587\u4ef6\u662f\u4e00\u4e2a\u57fa\u672c\u6280\u80fd\uff0c\u4f46\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u4f60\u7684\u5f00\u53d1\u6548\u7387\u3002IDE\u63d0\u4f9b\u4e86\u4ee3\u7801\u7f16\u8f91\u3001\u8c03\u8bd5\u548c\u8fd0\u884c\u7b49\u529f\u80fd\uff0c\u4f7f\u5f00\u53d1\u8fc7\u7a0b\u66f4\u52a0\u9ad8\u6548\u3002<\/p>\n<\/p>\n<p><h4>7.1\u3001\u9009\u62e9\u5408\u9002\u7684IDE<\/h4>\n<\/p>\n<p><p>\u5e38\u89c1\u7684Python IDE\u5305\u62ecPyCharm\u3001Visual Studio Code\u3001Jupyter Notebook\u7b49\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u4e2a\u4eba\u559c\u597d\u9009\u62e9\u5408\u9002\u7684IDE\u3002<\/p>\n<\/p>\n<p><h4>7.2\u3001\u914d\u7f6eIDE<\/h4>\n<\/p>\n<p><p>\u5927\u591a\u6570IDE\u90fd\u652f\u6301\u4ece\u547d\u4ee4\u884c\u8fd0\u884cPython\u6587\u4ef6\u3002\u4f60\u53ef\u4ee5\u5728IDE\u4e2d\u914d\u7f6ePython\u89e3\u91ca\u5668\u548c\u73af\u5883\u53d8\u91cf\uff0c\u4f7fIDE\u80fd\u591f\u6b63\u786e\u8bc6\u522b\u548c\u8fd0\u884cPython\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h4>7.3\u3001\u4f7f\u7528IDE\u8fd0\u884cPython\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>\u5728\u914d\u7f6e\u597dIDE\u540e\uff0c\u4f60\u53ef\u4ee5\u76f4\u63a5\u5728IDE\u4e2d\u8fd0\u884cPython\u6587\u4ef6\uff0c\u800c\u65e0\u9700\u6bcf\u6b21\u90fd\u624b\u52a8\u6253\u5f00\u547d\u4ee4\u884c\u3002\u8fd9\u4f7f\u5f97\u5f00\u53d1\u8fc7\u7a0b\u66f4\u52a0\u4fbf\u6377\u3002<\/p>\n<\/p>\n<p><h3>\u4e5d\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u4ece\u547d\u4ee4\u884c\u6253\u5f00\u548c\u8fd0\u884cPython\u6587\u4ef6\u662f\u6bcf\u4e2aPython\u5f00\u53d1\u8005\u5e94\u638c\u63e1\u7684\u57fa\u672c\u6280\u80fd\u3002\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u4f60\u5e94\u8be5\u5df2\u7ecf\u4e86\u89e3\u4e86\u5982\u4f55\u786e\u4fdd\u6587\u4ef6\u8def\u5f84\u6b63\u786e\u3001\u4f7f\u7528Python\u89e3\u91ca\u5668\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u5904\u7406\u5e38\u89c1\u95ee\u9898\u3001\u4f20\u9012\u547d\u4ee4\u884c\u53c2\u6570\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u4ee5\u53ca\u9009\u62e9\u548c\u914d\u7f6eIDE\u3002\u638c\u63e1\u8fd9\u4e9b\u6280\u80fd\u5c06\u5e2e\u52a9\u4f60\u66f4\u52a0\u9ad8\u6548\u5730\u5f00\u53d1\u548c\u8fd0\u884cPython\u9879\u76ee\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728\u547d\u4ee4\u884c\u4e2d\u6253\u5f00Python\u6587\u4ef6\uff1f<\/strong><br \/>\u8981\u5728\u547d\u4ee4\u884c\u4e2d\u6253\u5f00Python\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u9996\u5148\uff0c\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u7a97\u53e3\uff0c\u7136\u540e\u4f7f\u7528<code>cd<\/code>\u547d\u4ee4\u5bfc\u822a\u5230\u5305\u542bPython\u6587\u4ef6\u7684\u76ee\u5f55\u3002\u63a5\u7740\uff0c\u8f93\u5165<code>python \u6587\u4ef6\u540d.py<\/code>\u5e76\u6309\u4e0b\u56de\u8f66\u952e\uff0c\u5373\u53ef\u8fd0\u884c\u8be5\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u8f93\u5165<code>python myscript.py<\/code>\u3002<\/p>\n<p><strong>\u5728\u547d\u4ee4\u884c\u4e2d\u5982\u4f55\u67e5\u770bPython\u811a\u672c\u7684\u8f93\u51fa\u7ed3\u679c\uff1f<\/strong><br \/>\u5728\u8fd0\u884cPython\u811a\u672c\u540e\uff0c\u8f93\u51fa\u7ed3\u679c\u4f1a\u76f4\u63a5\u663e\u793a\u5728\u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u3002\u5982\u679c\u811a\u672c\u4e2d\u5305\u542b<code>print()<\/code>\u51fd\u6570\uff0c\u8f93\u51fa\u5185\u5bb9\u5c06\u4f1a\u5728\u63a7\u5236\u53f0\u4e0a\u53ef\u89c1\u3002\u82e5\u9700\u8981\u5c06\u8f93\u51fa\u7ed3\u679c\u4fdd\u5b58\u5230\u6587\u4ef6\u4e2d\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u4e2d\u4f7f\u7528\u91cd\u5b9a\u5411\u7b26\u53f7\uff0c\u4f8b\u5982<code>python myscript.py &gt; output.txt<\/code>\uff0c\u8fd9\u6837\u8f93\u51fa\u5c06\u88ab\u5199\u5165\u5230<code>output.txt<\/code>\u6587\u4ef6\u4e2d\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728\u547d\u4ee4\u884c\u4e2d\u6267\u884c\u5e26\u6709\u53c2\u6570\u7684Python\u811a\u672c\uff1f<\/strong><br \/>\u82e5\u8981\u5728\u547d\u4ee4\u884c\u4e2d\u6267\u884c\u5e26\u6709\u53c2\u6570\u7684Python\u811a\u672c\uff0c\u53ef\u4ee5\u5728\u8fd0\u884c\u547d\u4ee4\u65f6\u5728\u6587\u4ef6\u540d\u540e\u6dfb\u52a0\u6240\u9700\u7684\u53c2\u6570\u3002\u4f8b\u5982\uff0c<code>python myscript.py arg1 arg2<\/code>\u3002\u5728\u811a\u672c\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>sys.argv<\/code>\u5217\u8868\u6765\u8bbf\u95ee\u8fd9\u4e9b\u53c2\u6570\u3002\u786e\u4fdd\u5728\u811a\u672c\u4e2d\u5904\u7406\u8fd9\u4e9b\u53c2\u6570\uff0c\u4ee5\u5b9e\u73b0\u9884\u671f\u7684\u529f\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4e00\u3001\u5982\u4f55\u4ece\u547d\u4ee4\u884c\u6253\u5f00Python\u6587\u4ef6 \u8981\u4ece\u547d\u4ee4\u884c\u6253\u5f00Python\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u8f93\u5165\u547d\u4ee4\u3001\u786e\u4fdd\u6587\u4ef6\u8def\u5f84\u6b63\u786e [&hellip;]","protected":false},"author":3,"featured_media":1132775,"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\/1132763"}],"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=1132763"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1132763\/revisions"}],"predecessor-version":[{"id":1132776,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1132763\/revisions\/1132776"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1132775"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1132763"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1132763"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1132763"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}