{"id":936939,"date":"2024-12-26T19:40:08","date_gmt":"2024-12-26T11:40:08","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/936939.html"},"modified":"2024-12-26T19:40:10","modified_gmt":"2024-12-26T11:40:10","slug":"idea-%e5%a6%82%e4%bd%95%e8%bf%90%e8%a1%8cpython","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/936939.html","title":{"rendered":"idea \u5982\u4f55\u8fd0\u884cpython"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25073011\/2a9e0a75-1a2e-4b60-a118-5ba51e210dfb.webp\" alt=\"idea \u5982\u4f55\u8fd0\u884cpython\" \/><\/p>\n<p><p> <strong>\u8981\u8fd0\u884cPython\u7a0b\u5e8f\uff0c\u4f60\u9700\u8981\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u7f16\u5199Python\u4ee3\u7801\u3001\u5728\u547d\u4ee4\u884c\u6216\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u4e2d\u6267\u884c\u811a\u672c\u3002<\/strong> \u63a8\u8350\u4f7f\u7528Python\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u3001\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u6216IDE\u7f16\u5199\u4ee3\u7801\u3001\u901a\u8fc7\u547d\u4ee4\u884c\u6216IDE\u7684\u8fd0\u884c\u529f\u80fd\u6267\u884c\u811a\u672c\u3002\u8fd9\u4e9b\u6b65\u9aa4\u786e\u4fdd\u4f60\u80fd\u591f\u6709\u6548\u5730\u8fd0\u884cPython\u7a0b\u5e8f\uff0c\u5e76\u4f53\u9a8c\u5176\u5f3a\u5927\u7684\u529f\u80fd\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u63a2\u8ba8\u6bcf\u4e2a\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5b89\u88c5Python\u89e3\u91ca\u5668  <\/p>\n<\/p>\n<p><p>\u8981\u8fd0\u884cPython\u7a0b\u5e8f\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Python\u89e3\u91ca\u5668\u3002Python\u89e3\u91ca\u5668\u662f\u5c06Python\u4ee3\u7801\u7ffb\u8bd1\u4e3a\u673a\u5668\u4ee3\u7801\u7684\u5de5\u5177\uff0c\u4f7f\u8ba1\u7b97\u673a\u80fd\u591f\u7406\u89e3\u548c\u6267\u884cPython\u7a0b\u5e8f\u3002\u76ee\u524d\uff0cPython\u6709\u4e24\u4e2a\u4e3b\u8981\u7248\u672c\uff1aPython 2\u548cPython 3\u3002Python 3\u662f\u6700\u65b0\u7684\u7248\u672c\uff0cPython 2\u5df2\u7ecf\u4e0d\u518d\u5b98\u65b9\u652f\u6301\uff0c\u56e0\u6b64\u5efa\u8bae\u5b89\u88c5Python 3\u3002\u4ee5\u4e0b\u662f\u5b89\u88c5Python\u89e3\u91ca\u5668\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4e0b\u8f7dPython<\/strong>\uff1a\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%EF%BC%8C%E5%9C%A8%E4%B8%8B%E8%BD%BD%E9%A1%B5%E9%9D%A2%E9%80%89%E6%8B%A9%E9%80%82%E5%90%88%E4%BD%A0%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E7%9A%84%E5%AE%89%E8%A3%85%E5%8C%85%E3%80%82Windows%E3%80%81macOS%E5%92%8CLinux%E9%83%BD%E6%9C%89%E7%9B%B8%E5%BA%94%E7%9A%84%E5%AE%89%E8%A3%85%E5%8C%85%E3%80%82\">https:\/\/www.python.org\/\uff09\uff0c\u5728\u4e0b\u8f7d\u9875\u9762\u9009\u62e9\u9002\u5408\u4f60\u64cd\u4f5c\u7cfb\u7edf\u7684\u5b89\u88c5\u5305\u3002Windows\u3001macOS\u548cLinux\u90fd\u6709\u76f8\u5e94\u7684\u5b89\u88c5\u5305\u3002<\/a><\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Python<\/strong>\uff1a\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u8fd0\u884c\u5b89\u88c5\u5305\u3002\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u9009\u62e9\u6dfb\u52a0Python\u5230\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\uff0c\u8fd9\u5c06\u4f7f\u4f60\u80fd\u591f\u5728\u547d\u4ee4\u884c\u4e2d\u76f4\u63a5\u8fd0\u884cPython\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u547d\u4ee4\u884c\uff08Windows\u7528\u6237\u53ef\u4ee5\u4f7f\u7528cmd\uff0cmacOS\u548cLinux\u7528\u6237\u53ef\u4ee5\u4f7f\u7528\u7ec8\u7aef\uff09\uff0c\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002\u5982\u679c\u5b89\u88c5\u6210\u529f\uff0c\u547d\u4ee4\u884c\u5c06\u663e\u793aPython\u7684\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u7f16\u5199Python\u4ee3\u7801  <\/p>\n<\/p>\n<p><p>\u5b89\u88c5Python\u89e3\u91ca\u5668\u540e\uff0c\u4e0b\u4e00\u6b65\u662f\u7f16\u5199Python\u4ee3\u7801\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u6587\u672c\u7f16\u8f91\u5668\u6216\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u6765\u7f16\u5199Python\u4ee3\u7801\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u5de5\u5177\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6587\u672c\u7f16\u8f91\u5668<\/strong>\uff1a\u5982Notepad++\u3001Sublime Text\u3001Visual Studio Code\u7b49\u3002\u8fd9\u4e9b\u5de5\u5177\u8f7b\u91cf\u7ea7\u4e14\u6613\u4e8e\u4f7f\u7528\uff0c\u9002\u5408\u7f16\u5199\u7b80\u5355\u7684Python\u811a\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09<\/strong>\uff1a\u5982PyCharm\u3001Spyder\u3001Jupyter Notebook\u7b49\u3002\u8fd9\u4e9b\u5de5\u5177\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u529f\u80fd\uff0c\u5982\u4ee3\u7801\u8865\u5168\u3001\u8c03\u8bd5\u3001\u7248\u672c\u63a7\u5236\u7b49\uff0c\u9002\u5408\u5927\u578b\u9879\u76ee\u7684\u5f00\u53d1\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u7f16\u5199Python\u4ee3\u7801\u65f6\uff0c\u9700\u8981\u5c06\u4ee3\u7801\u4fdd\u5b58\u4e3a<code>.py<\/code>\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>hello.py<\/code>\u7684\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u7f16\u5199\u5982\u4e0b\u7b80\u5355\u7684\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<p><p>\u4e09\u3001\u8fd0\u884cPython\u811a\u672c  <\/p>\n<\/p>\n<p><p>\u7f16\u5199\u5b8cPython\u4ee3\u7801\u540e\uff0c\u5c31\u53ef\u4ee5\u8fd0\u884c\u811a\u672c\u4e86\u3002\u8fd0\u884cPython\u811a\u672c\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u4ee5\u4e0b\u662f\u5e38\u89c1\u7684\u51e0\u79cd\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528\u547d\u4ee4\u884c\u8fd0\u884c<\/strong>\uff1a\u6253\u5f00\u547d\u4ee4\u884c\uff0c\u5bfc\u822a\u5230\u4fdd\u5b58Python\u811a\u672c\u7684\u76ee\u5f55\uff0c\u8f93\u5165<code>python filename.py<\/code>\u6216<code>python3 filename.py<\/code>\u6765\u8fd0\u884c\u811a\u672c\u3002\u4f8b\u5982\uff0c\u8fd0\u884c\u524d\u9762\u521b\u5efa\u7684<code>hello.py<\/code>\u811a\u672c\uff0c\u8f93\u5165<code>python hello.py<\/code>\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528IDE\u8fd0\u884c<\/strong>\uff1a\u5982\u679c\u4f7f\u7528IDE\u7f16\u5199\u4ee3\u7801\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728IDE\u4e2d\u8fd0\u884c\u811a\u672c\u3002\u5927\u591a\u6570IDE\u90fd\u63d0\u4f9b\u4e86\u8fd0\u884c\u6309\u94ae\u6216\u5feb\u6377\u952e\u6765\u6267\u884cPython\u4ee3\u7801\u3002\u4f8b\u5982\uff0c\u5728PyCharm\u4e2d\uff0c\u53ef\u4ee5\u70b9\u51fb\u8fd0\u884c\u6309\u94ae\u6216\u6309Shift+F10\u6765\u8fd0\u884c\u811a\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528Jupyter Notebook<\/strong>\uff1a\u5982\u679c\u4f7f\u7528Jupyter Notebook\u7f16\u5199\u4ee3\u7801\uff0c\u53ef\u4ee5\u5728\u5355\u5143\u683c\u4e2d\u8f93\u5165Python\u4ee3\u7801\uff0c\u7136\u540e\u6309Shift+Enter\u6765\u6267\u884c\u4ee3\u7801\u3002Jupyter Notebook\u9002\u5408\u7528\u4e8e\u6570\u636e\u5206\u6790\u548c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u9879\u76ee\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u8c03\u8bd5\u548c\u4f18\u5316Python\u4ee3\u7801  <\/p>\n<\/p>\n<p><p>\u5728\u8fd0\u884cPython\u7a0b\u5e8f\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u9519\u8bef\u6216\u9700\u8981\u4f18\u5316\u4ee3\u7801\u3002\u8fd9\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u8c03\u8bd5\u5de5\u5177\u548c\u4f18\u5316\u6280\u5de7\u6765\u6539\u8fdb\u4ee3\u7801\u7684\u6027\u80fd\u548c\u53ef\u9760\u6027\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8c03\u8bd5\u5de5\u5177<\/strong>\uff1aPython\u63d0\u4f9b\u4e86\u591a\u79cd\u8c03\u8bd5\u5de5\u5177\uff0c\u5982pdb\u3001ipdb\u3001pylint\u7b49\u3002\u8fd9\u4e9b\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u4f60\u67e5\u627e\u548c\u4fee\u590d\u4ee3\u7801\u4e2d\u7684\u9519\u8bef\u3002\u4f8b\u5982\uff0cpdb\u662fPython\u7684\u5185\u7f6e\u8c03\u8bd5\u5668\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528\uff0c\u901a\u8fc7\u8bbe\u7f6e\u65ad\u70b9\u3001\u5355\u6b65\u6267\u884c\u4ee3\u7801\u3001\u68c0\u67e5\u53d8\u91cf\u503c\u7b49\u65b9\u5f0f\u6765\u8c03\u8bd5\u4ee3\u7801\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f18\u5316\u6280\u5de7<\/strong>\uff1a\u5728\u7f16\u5199Python\u4ee3\u7801\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u4f18\u5316\u6280\u5de7\u6765\u63d0\u9ad8\u4ee3\u7801\u7684\u6027\u80fd\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u751f\u6210\u5668\u66ff\u4ee3\u5217\u8868\u53ef\u4ee5\u8282\u7701\u5185\u5b58\uff0c\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u548c\u5e93\u51fd\u6570\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u6267\u884c\u901f\u5ea6\uff0c\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u91cd\u590d\u8ba1\u7b97\u7b49\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u603b\u7ed3  <\/p>\n<\/p>\n<p><p>\u8fd0\u884cPython\u7a0b\u5e8f\u662f\u4e00\u4e2a\u4ece\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u7f16\u5199\u4ee3\u7801\u5230\u6267\u884c\u811a\u672c\u7684\u8fc7\u7a0b\u3002\u901a\u8fc7\u638c\u63e1\u5b89\u88c5\u3001\u7f16\u5199\u548c\u8fd0\u884cPython\u4ee3\u7801\u7684\u57fa\u672c\u6b65\u9aa4\uff0c\u4ee5\u53ca\u4f7f\u7528\u8c03\u8bd5\u5de5\u5177\u548c\u4f18\u5316\u6280\u5de7\uff0c\u4f60\u53ef\u4ee5\u66f4\u52a0\u9ad8\u6548\u5730\u8fdb\u884cPython\u7f16\u7a0b\u3002\u65e0\u8bba\u662f\u521d\u5b66\u8005\u8fd8\u662f\u6709\u7ecf\u9a8c\u7684\u5f00\u53d1\u8005\uff0c\u8fd9\u4e9b\u6b65\u9aa4\u548c\u6280\u5de7\u90fd\u662f\u5fc5\u5907\u7684\u57fa\u7840\u6280\u80fd\u3002\u5e0c\u671b\u672c\u6587\u80fd\u591f\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7406\u89e3\u548c\u5e94\u7528Python\uff0c\u4eab\u53d7\u7f16\u7a0b\u7684\u4e50\u8da3\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728IDEA\u4e2d\u914d\u7f6ePython\u73af\u5883\uff1f<\/strong><br \/>\u5728IDEA\u4e2d\u8fd0\u884cPython\u4e4b\u524d\uff0c\u9700\u8981\u786e\u4fdd\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u63d2\u4ef6\u3002\u53ef\u4ee5\u901a\u8fc7\u6253\u5f00IDEA\uff0c\u8fdb\u5165\u201cFile\u201d -&gt; \u201cSettings\u201d -&gt; \u201cPlugins\u201d\uff0c\u641c\u7d22\u5e76\u5b89\u88c5Python\u63d2\u4ef6\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python\u9879\u76ee\uff0c\u5e76\u5728\u9879\u76ee\u8bbe\u7f6e\u4e2d\u9009\u62e9Python\u89e3\u91ca\u5668\uff0c\u786e\u4fddIDEA\u80fd\u591f\u627e\u5230\u5df2\u5b89\u88c5\u7684Python\u7248\u672c\u3002<\/p>\n<p><strong>\u5728IDEA\u4e2d\u5982\u4f55\u521b\u5efa\u5e76\u8fd0\u884cPython\u811a\u672c\uff1f<\/strong><br \/>\u5728IDEA\u4e2d\u521b\u5efaPython\u811a\u672c\u975e\u5e38\u7b80\u5355\u3002\u53ef\u4ee5\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u53f3\u952e\u70b9\u51fb\uff0c\u9009\u62e9\u201cNew\u201d -&gt; \u201cPython File\u201d\uff0c\u8f93\u5165\u6587\u4ef6\u540d\u540e\u70b9\u51fb\u201cOK\u201d\u3002\u5728\u65b0\u5efa\u7684\u6587\u4ef6\u4e2d\u7f16\u5199Python\u4ee3\u7801\u540e\uff0c\u53f3\u952e\u70b9\u51fb\u4ee3\u7801\u7a97\u53e3\uff0c\u9009\u62e9\u201cRun &#39;\u6587\u4ef6\u540d&#39;\u201d\u5373\u53ef\u8fd0\u884c\u8be5\u811a\u672c\uff0c\u63a7\u5236\u53f0\u5c06\u663e\u793a\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728IDEA\u4e2d\u8c03\u8bd5Python\u4ee3\u7801\uff1f<\/strong><br \/>\u8c03\u8bd5Python\u4ee3\u7801\u7684\u8fc7\u7a0b\u53ef\u4ee5\u901a\u8fc7\u5728IDEA\u4e2d\u8bbe\u7f6e\u65ad\u70b9\u6765\u5b9e\u73b0\u3002\u53ea\u9700\u5728\u4ee3\u7801\u884c\u53f7\u533a\u57df\u70b9\u51fb\uff0c\u5373\u53ef\u8bbe\u7f6e\u65ad\u70b9\u3002\u63a5\u7740\uff0c\u53f3\u952e\u70b9\u51fb\u4ee3\u7801\u7a97\u53e3\uff0c\u9009\u62e9\u201cDebug &#39;\u6587\u4ef6\u540d&#39;\u201d\u8fdb\u884c\u8c03\u8bd5\u3002\u8c03\u8bd5\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u9010\u6b65\u6267\u884c\u4ee3\u7801\uff0c\u67e5\u770b\u53d8\u91cf\u503c\uff0c\u5e2e\u52a9\u8bc6\u522b\u548c\u4fee\u590d\u4ee3\u7801\u4e2d\u7684\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u8fd0\u884cPython\u7a0b\u5e8f\uff0c\u4f60\u9700\u8981\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u7f16\u5199Python\u4ee3\u7801\u3001\u5728\u547d\u4ee4\u884c\u6216\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u4e2d [&hellip;]","protected":false},"author":3,"featured_media":936944,"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\/936939"}],"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=936939"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/936939\/revisions"}],"predecessor-version":[{"id":936945,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/936939\/revisions\/936945"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/936944"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=936939"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=936939"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=936939"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}