{"id":1057819,"date":"2024-12-31T15:11:14","date_gmt":"2024-12-31T07:11:14","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1057819.html"},"modified":"2024-12-31T15:11:17","modified_gmt":"2024-12-31T07:11:17","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8pycharm%e4%b8%8a%e4%bd%bf%e7%94%a8python3","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1057819.html","title":{"rendered":"\u5982\u4f55\u5728pycharm\u4e0a\u4f7f\u7528python3"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/833bc4fd-fe16-4298-aaed-dd4cfa198c8c.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"\u5982\u4f55\u5728pycharm\u4e0a\u4f7f\u7528python3\" \/><\/p>\n<p><p> <strong>\u5728PyCharm\u4e0a\u4f7f\u7528Python3\u7684\u6b65\u9aa4\u5305\u62ec\u5b89\u88c5PyCharm\u3001\u5b89\u88c5Python3\u3001\u914d\u7f6e\u89e3\u91ca\u5668\u3001\u521b\u5efa\u65b0\u9879\u76ee\u3001\u7f16\u5199\u548c\u8fd0\u884c\u4ee3\u7801\u3001\u8c03\u8bd5\u4ee3\u7801\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u3001\u5b89\u88c5\u548c\u7ba1\u7406\u5e93\u3002<\/strong> \u5176\u4e2d\uff0c\u914d\u7f6e\u89e3\u91ca\u5668\u662f\u6700\u91cd\u8981\u7684\u6b65\u9aa4\uff0c\u56e0\u4e3aPyCharm\u9700\u8981\u77e5\u9053Python3\u89e3\u91ca\u5668\u7684\u4f4d\u7f6e\uff0c\u4ee5\u4fbf\u6b63\u786e\u8fd0\u884cPython\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><p>\u8981\u5728PyCharm\u4e0a\u4f7f\u7528Python3\uff0c\u9996\u5148\u9700\u8981\u786e\u4fdd\u5df2\u7ecf\u5b89\u88c5\u4e86Python3\u548cPyCharm\u3002\u53ef\u4ee5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5Python3\uff0c\u4eceJetBr<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ns\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5PyCharm\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00PyCharm\u5e76\u914d\u7f6ePython3\u89e3\u91ca\u5668\u3002\u63a5\u4e0b\u6765\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\u5e76\u9009\u62e9Python3\u4f5c\u4e3a\u9879\u76ee\u7684\u89e3\u91ca\u5668\u3002\u53ef\u4ee5\u901a\u8fc7\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684Python\u811a\u672c\u6765\u6d4b\u8bd5\u914d\u7f6e\u662f\u5426\u6b63\u786e\uff0c\u4f8b\u5982\u6253\u5370\u201cHello, World!\u201d\u3002\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u4ee3\u7801\u5c06\u6210\u529f\u8fd0\u884c\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u5b89\u88c5PyCharm\u4e0ePython3<\/h2>\n<\/p>\n<p><h3>1\u3001\u4e0b\u8f7d\u5e76\u5b89\u88c5Python3<\/h3>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u4ecePython\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%E4%B8%8B%E8%BD%BDPython3%E7%9A%84%E5%AE%89%E8%A3%85%E5%8C%85%E3%80%82%E6%A0%B9%E6%8D%AE%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E9%80%89%E6%8B%A9%E5%90%88%E9%80%82%E7%9A%84%E7%89%88%E6%9C%AC%E8%BF%9B%E8%A1%8C%E4%B8%8B%E8%BD%BD%EF%BC%8C%E5%B9%B6%E6%8C%89%E7%85%A7%E6%8F%90%E7%A4%BA%E5%AE%8C%E6%88%90%E5%AE%89%E8%A3%85%E3%80%82%E5%9C%A8%E5%AE%89%E8%A3%85%E8%BF%87%E7%A8%8B%E4%B8%AD%EF%BC%8C%E7%A1%AE%E4%BF%9D%E5%8B%BE%E9%80%89%E2%80%9CAdd\">https:\/\/www.python.org\/\uff09\u4e0b\u8f7dPython3\u7684\u5b89\u88c5\u5305\u3002\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u9009\u62e9\u5408\u9002\u7684\u7248\u672c\u8fdb\u884c\u4e0b\u8f7d\uff0c\u5e76\u6309\u7167\u63d0\u793a\u5b8c\u6210\u5b89\u88c5\u3002\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u786e\u4fdd\u52fe\u9009\u201cAdd<\/a> Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u6837\u53ef\u4ee5\u65b9\u4fbf\u5730\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528Python\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u4e0b\u8f7d\u5e76\u5b89\u88c5PyCharm<\/h3>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u4eceJetBrains\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.jetbrains.com\/pycharm\/%EF%BC%89%E4%B8%8B%E8%BD%BDPyCharm%E7%9A%84%E7%A4%BE%E5%8C%BA%E7%89%88%E6%88%96%E4%B8%93%E4%B8%9A%E7%89%88%E3%80%82%E7%A4%BE%E5%8C%BA%E7%89%88%E6%98%AF%E5%85%8D%E8%B4%B9%E7%9A%84%EF%BC%8C%E9%80%82%E5%90%88%E4%B8%AA%E4%BA%BA%E9%A1%B9%E7%9B%AE%E5%92%8C%E5%AD%A6%E4%B9%A0%E4%BD%BF%E7%94%A8%E3%80%82%E4%B8%8B%E8%BD%BD%E5%AE%8C%E6%88%90%E5%90%8E%EF%BC%8C%E6%8C%89%E7%85%A7%E5%AE%89%E8%A3%85%E5%90%91%E5%AF%BC%E7%9A%84%E6%8F%90%E7%A4%BA%E5%AE%8C%E6%88%90%E5%AE%89%E8%A3%85%E3%80%82\">https:\/\/www.jetbrains.com\/pycharm\/\uff09\u4e0b\u8f7dPyCharm\u7684\u793e\u533a\u7248\u6216\u4e13\u4e1a\u7248\u3002\u793e\u533a\u7248\u662f\u514d\u8d39\u7684\uff0c\u9002\u5408\u4e2a\u4eba\u9879\u76ee\u548c\u5b66\u4e60\u4f7f\u7528\u3002\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u6309\u7167\u5b89\u88c5\u5411\u5bfc\u7684\u63d0\u793a\u5b8c\u6210\u5b89\u88c5\u3002<\/a><\/p>\n<\/p>\n<p><h2>\u4e8c\u3001\u914d\u7f6ePython3\u89e3\u91ca\u5668<\/h2>\n<\/p>\n<p><h3>1\u3001\u6253\u5f00PyCharm\u5e76\u521b\u5efa\u65b0\u9879\u76ee<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00PyCharm\u3002\u5728\u6b22\u8fce\u754c\u9762\uff0c\u70b9\u51fb\u201cCreate New Project\u201d\u6309\u94ae\u3002\u5728\u65b0\u9879\u76ee\u7a97\u53e3\u4e2d\uff0c\u9009\u62e9\u9879\u76ee\u7684\u4f4d\u7f6e\uff0c\u5e76\u5728\u201cProject Interpreter\u201d\u4e0b\u62c9\u83dc\u5355\u4e2d\u9009\u62e9\u201cNew Environment Using Virtualenv\u201d\u3002\u865a\u62df\u73af\u5883\u5c06\u5e2e\u52a9\u4f60\u5728\u9879\u76ee\u4e2d\u7ba1\u7406\u4f9d\u8d56\u9879\u548c\u5e93\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u9009\u62e9Python3\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<p><p>\u5728\u201cBase Interpreter\u201d\u4e0b\u62c9\u83dc\u5355\u4e2d\uff0c\u9009\u62e9\u5b89\u88c5\u7684Python3\u89e3\u91ca\u5668\u3002\u5982\u679cPython3\u89e3\u91ca\u5668\u6ca1\u6709\u51fa\u73b0\u5728\u5217\u8868\u4e2d\uff0c\u53ef\u4ee5\u70b9\u51fb\u53f3\u4fa7\u7684\u201c&#8230;\u201d\u6309\u94ae\uff0c\u624b\u52a8\u9009\u62e9Python3\u7684\u5b89\u88c5\u8def\u5f84\u3002\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u201cCreate\u201d\u6309\u94ae\u521b\u5efa\u65b0\u9879\u76ee\u3002<\/p>\n<\/p>\n<p><h2>\u4e09\u3001\u7f16\u5199\u548c\u8fd0\u884c\u4ee3\u7801<\/h2>\n<\/p>\n<p><h3>1\u3001\u521b\u5efa\u65b0\u7684Python\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u7a97\u53e3\u4e2d\uff0c\u53f3\u952e\u70b9\u51fb\u9879\u76ee\u540d\u79f0\uff0c\u9009\u62e9\u201cNew\u201d&gt;\u201cPython File\u201d\u3002\u4e3a\u65b0\u6587\u4ef6\u547d\u540d\uff0c\u4f8b\u5982\u201cmain.py\u201d\u3002\u5728\u65b0\u6587\u4ef6\u4e2d\uff0c\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684Python\u4ee3\u7801\uff0c\u4f8b\u5982\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><h3>2\u3001\u8fd0\u884cPython\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u53f3\u952e\u70b9\u51fb\u4ee3\u7801\u7f16\u8f91\u533a\u57df\uff0c\u9009\u62e9\u201cRun &#39;main&#39;\u201d\uff0c\u6216\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684\u8fd0\u884c\u6309\u94ae\u3002PyCharm\u5c06\u8fd0\u884c\u4ee3\u7801\uff0c\u5e76\u5728\u4e0b\u65b9\u7684\u8fd0\u884c\u7a97\u53e3\u4e2d\u663e\u793a\u8f93\u51fa\u7ed3\u679c\u3002\u5982\u679c\u770b\u5230\u201cHello, World!\u201d\u7684\u8f93\u51fa\uff0c\u8bf4\u660e\u914d\u7f6e\u6210\u529f\u3002<\/p>\n<\/p>\n<p><h2>\u56db\u3001\u8c03\u8bd5\u4ee3\u7801<\/h2>\n<\/p>\n<p><h3>1\u3001\u8bbe\u7f6e\u65ad\u70b9<\/h3>\n<\/p>\n<p><p>\u5728\u4ee3\u7801\u7f16\u8f91\u533a\u57df\u7684\u5de6\u4fa7\uff0c\u70b9\u51fb\u884c\u53f7\u65c1\u8fb9\u7684\u7070\u8272\u7a7a\u767d\u533a\u57df\uff0c\u8bbe\u7f6e\u65ad\u70b9\u3002\u65ad\u70b9\u662f\u4ee3\u7801\u6267\u884c\u65f6\u6682\u505c\u7684\u4f4d\u7f6e\uff0c\u4fbf\u4e8e\u68c0\u67e5\u53d8\u91cf\u7684\u503c\u548c\u7a0b\u5e8f\u7684\u6267\u884c\u6d41\u7a0b\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u5f00\u59cb\u8c03\u8bd5<\/h3>\n<\/p>\n<p><p>\u70b9\u51fb\u8fd0\u884c\u6309\u94ae\u65c1\u8fb9\u7684\u8c03\u8bd5\u6309\u94ae\uff0c\u6216\u53f3\u952e\u70b9\u51fb\u4ee3\u7801\u7f16\u8f91\u533a\u57df\uff0c\u9009\u62e9\u201cDebug &#39;main&#39;\u201d\u3002PyCharm\u5c06\u542f\u52a8\u8c03\u8bd5\u6a21\u5f0f\uff0c\u5e76\u5728\u65ad\u70b9\u5904\u6682\u505c\u6267\u884c\u3002\u53ef\u4ee5\u4f7f\u7528\u8c03\u8bd5\u5de5\u5177\u680f\u4e2d\u7684\u6309\u94ae\u5355\u6b65\u6267\u884c\u4ee3\u7801\u3001\u67e5\u770b\u53d8\u91cf\u503c\u548c\u8c03\u7528\u5806\u6808\u3002<\/p>\n<\/p>\n<p><h2>\u4e94\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883<\/h2>\n<\/p>\n<p><h3>1\u3001\u521b\u5efa\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u5728\u521b\u5efa\u65b0\u9879\u76ee\u65f6\uff0cPyCharm\u4f1a\u81ea\u52a8\u521b\u5efa\u4e00\u4e2a\u865a\u62df\u73af\u5883\u3002\u5982\u679c\u9700\u8981\u624b\u52a8\u521b\u5efa\u865a\u62df\u73af\u5883\uff0c\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u5728\u547d\u4ee4\u884c\u4e2d\uff0c\u5bfc\u822a\u5230\u865a\u62df\u73af\u5883\u7684\u76ee\u5f55\uff0c\u5e76\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\"># Windows<\/p>\n<p>myenv\\Scripts\\activate<\/p>\n<h2><strong>macOS\/Linux<\/strong><\/h2>\n<p>source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u53ef\u4ee5\u5728\u865a\u62df\u73af\u5883\u4e2d\u5b89\u88c5\u548c\u7ba1\u7406\u4f9d\u8d56\u9879\u3002<\/p>\n<\/p>\n<p><h2>\u516d\u3001\u5b89\u88c5\u548c\u7ba1\u7406\u5e93<\/h2>\n<\/p>\n<p><h3>1\u3001\u4f7f\u7528pip\u5b89\u88c5\u5e93<\/h3>\n<\/p>\n<p><p>\u5728PyCharm\u7684\u7ec8\u7aef\u7a97\u53e3\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u5b89\u88c5\u5e93\u3002\u4f8b\u5982\uff0c\u5b89\u88c5requests\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u7ba1\u7406\u5e93<\/h3>\n<\/p>\n<p><p>\u5728PyCharm\u7684\u201cProject\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u9879\u76ee\u540d\u79f0\uff0c\u9009\u62e9\u201cFile\u201d&gt;\u201cSettings\u201d&gt;\u201cProject\u201d&gt;\u201cProject Interpreter\u201d\u3002\u5728\u9879\u76ee\u89e3\u91ca\u5668\u7a97\u53e3\u4e2d\uff0c\u53ef\u4ee5\u67e5\u770b\u548c\u7ba1\u7406\u5df2\u5b89\u88c5\u7684\u5e93\u3002\u53ef\u4ee5\u70b9\u51fb\u201c+\u201d\u6309\u94ae\u641c\u7d22\u5e76\u5b89\u88c5\u65b0\u5e93\uff0c\u70b9\u51fb\u201c-\u201d\u6309\u94ae\u5378\u8f7d\u4e0d\u9700\u8981\u7684\u5e93\u3002<\/p>\n<\/p>\n<p><h2>\u4e03\u3001\u914d\u7f6e\u9879\u76ee\u89e3\u91ca\u5668<\/h2>\n<\/p>\n<p><h3>1\u3001\u68c0\u67e5\u9879\u76ee\u89e3\u91ca\u5668\u914d\u7f6e<\/h3>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u9879\u76ee\u540d\u79f0\uff0c\u9009\u62e9\u201cFile\u201d&gt;\u201cSettings\u201d&gt;\u201cProject\u201d&gt;\u201cProject Interpreter\u201d\u3002\u786e\u4fdd\u5df2\u9009\u62e9\u6b63\u786e\u7684Python3\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u6dfb\u52a0\u65b0\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u9700\u8981\u6dfb\u52a0\u65b0\u7684\u89e3\u91ca\u5668\uff0c\u53ef\u4ee5\u70b9\u51fb\u53f3\u4fa7\u7684\u201c&#8230;\u201d\u6309\u94ae\uff0c\u9009\u62e9\u201cAdd Interpreter\u201d&gt;\u201cSystem Interpreter\u201d\uff0c\u7136\u540e\u9009\u62e9Python3\u7684\u5b89\u88c5\u8def\u5f84\u3002<\/p>\n<\/p>\n<p><h2>\u516b\u3001\u4f7f\u7528\u7248\u672c\u63a7\u5236<\/h2>\n<\/p>\n<p><h3>1\u3001\u914d\u7f6eGit<\/h3>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u9879\u76ee\u540d\u79f0\uff0c\u9009\u62e9\u201cVCS\u201d&gt;\u201cEnable Version Control Integration\u201d\u3002\u9009\u62e9\u201cGit\u201d\u4f5c\u4e3a\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u3002PyCharm\u5c06\u81ea\u52a8\u521d\u59cb\u5316Git\u4ed3\u5e93\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u63d0\u4ea4\u66f4\u6539<\/h3>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u7a97\u53e3\u4e2d\uff0c\u53f3\u952e\u70b9\u51fb\u6587\u4ef6\u6216\u6587\u4ef6\u5939\uff0c\u9009\u62e9\u201cGit\u201d&gt;\u201cCommit File\u201d\u3002\u586b\u5199\u63d0\u4ea4\u4fe1\u606f\uff0c\u70b9\u51fb\u201cCommit\u201d\u6309\u94ae\u63d0\u4ea4\u66f4\u6539\u3002<\/p>\n<\/p>\n<p><h3>3\u3001\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93<\/h3>\n<\/p>\n<p><p>\u914d\u7f6e\u8fdc\u7a0b\u4ed3\u5e93\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u201cGit\u201d&gt;\u201cPush\u201d\u5c06\u66f4\u6539\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\u3002<\/p>\n<\/p>\n<p><h2>\u4e5d\u3001\u4f7f\u7528\u4ee3\u7801\u98ce\u683c\u68c0\u67e5\u548c\u683c\u5f0f\u5316\u5de5\u5177<\/h2>\n<\/p>\n<p><h3>1\u3001\u914d\u7f6e\u4ee3\u7801\u98ce\u683c<\/h3>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u9879\u76ee\u540d\u79f0\uff0c\u9009\u62e9\u201cFile\u201d&gt;\u201cSettings\u201d&gt;\u201cEditor\u201d&gt;\u201cCode Style\u201d&gt;\u201cPython\u201d\u3002\u53ef\u4ee5\u6839\u636e\u56e2\u961f\u6216\u4e2a\u4eba\u7684\u7f16\u7801\u89c4\u8303\u914d\u7f6e\u4ee3\u7801\u98ce\u683c\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u4f7f\u7528\u683c\u5f0f\u5316\u5de5\u5177<\/h3>\n<\/p>\n<p><p>PyCharm\u652f\u6301\u591a\u79cd\u683c\u5f0f\u5316\u5de5\u5177\uff0c\u4f8b\u5982black\u548cyapf\u3002\u5728\u7ec8\u7aef\u7a97\u53e3\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u5b89\u88c5\u8fd9\u4e9b\u5de5\u5177\u3002\u4f8b\u5982\uff0c\u5b89\u88c5black\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install black<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884cblack\u547d\u4ee4\u683c\u5f0f\u5316\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">black .<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u5341\u3001\u4f7f\u7528\u5355\u5143\u6d4b\u8bd5<\/h2>\n<\/p>\n<p><h3>1\u3001\u7f16\u5199\u5355\u5143\u6d4b\u8bd5<\/h3>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u7a97\u53e3\u4e2d\uff0c\u53f3\u952e\u70b9\u51fb\u9879\u76ee\u540d\u79f0\uff0c\u9009\u62e9\u201cNew\u201d&gt;\u201cPython File\u201d\u3002\u4e3a\u6d4b\u8bd5\u6587\u4ef6\u547d\u540d\uff0c\u4f8b\u5982\u201ctest_main.py\u201d\u3002\u7f16\u5199\u5355\u5143\u6d4b\u8bd5\u4ee3\u7801\uff0c\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import unittest<\/p>\n<p>from main import add<\/p>\n<p>class TestAdd(unittest.TestCase):<\/p>\n<p>    def test_add(self):<\/p>\n<p>        self.assertEqual(add(1, 2), 3)<\/p>\n<p>if __name__ == &quot;__main__&quot;:<\/p>\n<p>    unittest.main()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u8fd0\u884c\u5355\u5143\u6d4b\u8bd5<\/h3>\n<\/p>\n<p><p>\u53f3\u952e\u70b9\u51fb\u4ee3\u7801\u7f16\u8f91\u533a\u57df\uff0c\u9009\u62e9\u201cRun &#39;test_main&#39;\u201d\uff0c\u6216\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684\u8fd0\u884c\u6309\u94ae\u3002PyCharm\u5c06\u8fd0\u884c\u5355\u5143\u6d4b\u8bd5\uff0c\u5e76\u5728\u4e0b\u65b9\u7684\u8fd0\u884c\u7a97\u53e3\u4e2d\u663e\u793a\u6d4b\u8bd5\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h2>\u5341\u4e00\u3001\u914d\u7f6e\u4ee3\u7801\u8865\u5168\u548c\u63d0\u793a<\/h2>\n<\/p>\n<p><h3>1\u3001\u68c0\u67e5\u4ee3\u7801\u8865\u5168\u8bbe\u7f6e<\/h3>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u9879\u76ee\u540d\u79f0\uff0c\u9009\u62e9\u201cFile\u201d&gt;\u201cSettings\u201d&gt;\u201cEditor\u201d&gt;\u201cGeneral\u201d&gt;\u201cCode Completion\u201d\u3002\u786e\u4fdd\u5df2\u542f\u7528\u4ee3\u7801\u8865\u5168\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u4f7f\u7528\u4ee3\u7801\u8865\u5168<\/h3>\n<\/p>\n<p><p>\u5728\u4ee3\u7801\u7f16\u8f91\u533a\u57df\uff0c\u5f00\u59cb\u8f93\u5165\u4ee3\u7801\u65f6\uff0cPyCharm\u4f1a\u81ea\u52a8\u663e\u793a\u4ee3\u7801\u8865\u5168\u63d0\u793a\u3002\u53ef\u4ee5\u4f7f\u7528Tab\u952e\u9009\u62e9\u5efa\u8bae\u7684\u4ee3\u7801\u8865\u5168\u9879\u3002<\/p>\n<\/p>\n<p><h2>\u5341\u4e8c\u3001\u4f7f\u7528\u6570\u636e\u5e93\u5de5\u5177<\/h2>\n<\/p>\n<p><h3>1\u3001\u914d\u7f6e\u6570\u636e\u5e93\u8fde\u63a5<\/h3>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u9879\u76ee\u540d\u79f0\uff0c\u9009\u62e9\u201cView\u201d&gt;\u201cTool Windows\u201d&gt;\u201cDatabase\u201d\u3002\u70b9\u51fb\u5de6\u4e0a\u89d2\u7684\u201c+\u201d\u6309\u94ae\uff0c\u9009\u62e9\u6570\u636e\u5e93\u7c7b\u578b\uff0c\u5e76\u586b\u5199\u6570\u636e\u5e93\u8fde\u63a5\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u6267\u884cSQL\u67e5\u8be2<\/h3>\n<\/p>\n<p><p>\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5728\u201cDatabase\u201d\u7a97\u53e3\u4e2d\u6d4f\u89c8\u6570\u636e\u5e93\u8868\u548c\u6570\u636e\u3002\u53f3\u952e\u70b9\u51fb\u6570\u636e\u5e93\u8868\uff0c\u9009\u62e9\u201cJump to Data\u201d\u67e5\u770b\u8868\u6570\u636e\u3002\u53ef\u4ee5\u5728SQL\u7f16\u8f91\u5668\u4e2d\u7f16\u5199\u548c\u6267\u884cSQL\u67e5\u8be2\u3002<\/p>\n<\/p>\n<p><h2>\u5341\u4e09\u3001\u4f7f\u7528\u8fdc\u7a0b\u5f00\u53d1\u5de5\u5177<\/h2>\n<\/p>\n<p><h3>1\u3001\u914d\u7f6e\u8fdc\u7a0b\u670d\u52a1\u5668<\/h3>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u9879\u76ee\u540d\u79f0\uff0c\u9009\u62e9\u201cFile\u201d&gt;\u201cSettings\u201d&gt;\u201cProject\u201d&gt;\u201cProject Interpreter\u201d\u3002\u70b9\u51fb\u53f3\u4fa7\u7684\u201c&#8230;\u201d\u6309\u94ae\uff0c\u9009\u62e9\u201cAdd Interpreter\u201d&gt;\u201cSSH Interpreter\u201d\uff0c\u586b\u5199\u8fdc\u7a0b\u670d\u52a1\u5668\u7684SSH\u8fde\u63a5\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u90e8\u7f72\u4ee3\u7801\u5230\u8fdc\u7a0b\u670d\u52a1\u5668<\/h3>\n<\/p>\n<p><p>\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5728\u9879\u76ee\u7a97\u53e3\u4e2d\u53f3\u952e\u70b9\u51fb\u6587\u4ef6\u6216\u6587\u4ef6\u5939\uff0c\u9009\u62e9\u201cDeployment\u201d&gt;\u201cUpload to\u2026\u201d\uff0c\u5c06\u4ee3\u7801\u90e8\u7f72\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u3002<\/p>\n<\/p>\n<p><h2>\u5341\u56db\u3001\u4f7f\u7528Docker<\/h2>\n<\/p>\n<p><h3>1\u3001\u914d\u7f6eDocker<\/h3>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u9879\u76ee\u540d\u79f0\uff0c\u9009\u62e9\u201cFile\u201d&gt;\u201cSettings\u201d&gt;\u201cBuild, Execution, Deployment\u201d&gt;\u201cDocker\u201d\u3002\u914d\u7f6eDocker\u4e3b\u673a\u8fde\u63a5\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u4f7f\u7528Docker\u5bb9\u5668<\/h3>\n<\/p>\n<p><p>\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5728\u9879\u76ee\u7a97\u53e3\u4e2d\u53f3\u952e\u70b9\u51fbDockerfile\uff0c\u9009\u62e9\u201cRun &#39;Dockerfile&#39;\u201d\uff0c\u5728Docker\u5bb9\u5668\u4e2d\u8fd0\u884c\u9879\u76ee\u3002<\/p>\n<\/p>\n<p><h2>\u5341\u4e94\u3001\u4f18\u5316PyCharm\u6027\u80fd<\/h2>\n<\/p>\n<p><h3>1\u3001\u914d\u7f6e\u5185\u5b58\u548cCPU<\/h3>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u9879\u76ee\u540d\u79f0\uff0c\u9009\u62e9\u201cHelp\u201d&gt;\u201cEdit Custom VM Options\u201d\u3002\u6839\u636e\u7cfb\u7edf\u8d44\u6e90\u8c03\u6574\u5185\u5b58\u548cCPU\u914d\u7f6e\uff0c\u4f8b\u5982\u589e\u52a0Xmx\u503c\u4ee5\u5206\u914d\u66f4\u591a\u5185\u5b58\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u7981\u7528\u4e0d\u5fc5\u8981\u7684\u63d2\u4ef6<\/h3>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u9879\u76ee\u540d\u79f0\uff0c\u9009\u62e9\u201cFile\u201d&gt;\u201cSettings\u201d&gt;\u201cPlugins\u201d\u3002\u7981\u7528\u4e0d\u4f7f\u7528\u7684\u63d2\u4ef6\uff0c\u4ee5\u63d0\u9ad8PyCharm\u7684\u6027\u80fd\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u53ef\u4ee5\u5728PyCharm\u4e0a\u9ad8\u6548\u5730\u4f7f\u7528Python3\u8fdb\u884c\u5f00\u53d1\u3002PyCharm\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\u548c\u5de5\u5177\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u63d0\u9ad8\u751f\u4ea7\u529b\u548c\u4ee3\u7801\u8d28\u91cf\u3002\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff0c\u795d\u4f60\u5728Python\u5f00\u53d1\u4e2d\u53d6\u5f97\u66f4\u5927\u7684\u6210\u529f\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728PyCharm\u4e2d\u5982\u4f55\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python 3\u9879\u76ee\uff1f<\/strong><br \/>\u8981\u5728PyCharm\u4e2d\u521b\u5efa\u65b0\u7684Python 3\u9879\u76ee\uff0c\u53ef\u4ee5\u6253\u5f00PyCharm\u540e\uff0c\u9009\u62e9\u201cCreate New Project\u201d\u3002\u5728\u5f39\u51fa\u7684\u7a97\u53e3\u4e2d\uff0c\u9009\u62e9\u201cPython\u201d\u4f5c\u4e3a\u9879\u76ee\u7c7b\u578b\uff0c\u5e76\u786e\u4fddPython\u89e3\u91ca\u5668\u9009\u62e9\u7684\u662fPython 3\u7684\u7248\u672c\u3002\u63a5\u4e0b\u6765\uff0c\u8bbe\u5b9a\u9879\u76ee\u540d\u79f0\u548c\u5b58\u50a8\u4f4d\u7f6e\uff0c\u70b9\u51fb\u201cCreate\u201d\u5373\u53ef\u5f00\u59cb\u4f60\u7684\u65b0\u9879\u76ee\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728PyCharm\u4e2d\u914d\u7f6ePython 3\u89e3\u91ca\u5668\uff1f<\/strong><br \/>\u5728PyCharm\u4e2d\u914d\u7f6ePython 3\u89e3\u91ca\u5668\u975e\u5e38\u7b80\u5355\u3002\u6253\u5f00\u9879\u76ee\u540e\uff0c\u70b9\u51fb\u201cFile\u201d\u83dc\u5355\uff0c\u9009\u62e9\u201cSettings\u201d\uff08\u5728Mac\u4e0a\u4e3a\u201cPreferences\u201d\uff09\u3002\u63a5\u7740\uff0c\u5728\u5de6\u4fa7\u83dc\u5355\u4e2d\u9009\u62e9\u201cProject: [\u9879\u76ee\u540d\u79f0]\u201d\u4e0b\u7684\u201cPython Interpreter\u201d\u3002\u5728\u8fd9\u91cc\uff0c\u4f60\u53ef\u4ee5\u6dfb\u52a0\u3001\u9009\u62e9\u6216\u66f4\u6539Python\u89e3\u91ca\u5668\uff0c\u786e\u4fdd\u9009\u4e2d\u7684\u662fPython 3\u7248\u672c\uff0c\u70b9\u51fb\u201cOK\u201d\u4fdd\u5b58\u8bbe\u7f6e\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728PyCharm\u4e2d\u5b89\u88c5\u548c\u4f7f\u7528Python 3\u7684\u5e93\uff1f<\/strong><br \/>\u5728PyCharm\u4e2d\u5b89\u88c5Python 3\u7684\u5e93\uff0c\u53ef\u4ee5\u901a\u8fc7\u5185\u7f6e\u7684\u5305\u7ba1\u7406\u5de5\u5177\u6765\u5b8c\u6210\u3002\u6253\u5f00\u9879\u76ee\u540e\uff0c\u8fdb\u5165\u201cFile\u201d\u83dc\u5355\uff0c\u9009\u62e9\u201cSettings\u201d\uff0c\u7136\u540e\u5728\u201cProject: [\u9879\u76ee\u540d\u79f0]\u201d\u4e0b\u627e\u5230\u201cPython Interpreter\u201d\u3002\u5728\u53f3\u4fa7\u53ef\u4ee5\u770b\u5230\u5df2\u7ecf\u5b89\u88c5\u7684\u5305\uff0c\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684\u201c+\u201d\u53f7\u6309\u94ae\uff0c\u641c\u7d22\u4f60\u60f3\u8981\u5b89\u88c5\u7684\u5e93\uff0c\u5982\u201cnumpy\u201d\u6216\u201cpandas\u201d\uff0c\u9009\u4e2d\u540e\u70b9\u51fb\u201cInstall Package\u201d\u8fdb\u884c\u5b89\u88c5\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u5c31\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u5bfc\u5165\u5e76\u4f7f\u7528\u8fd9\u4e9b\u5e93\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728PyCharm\u4e0a\u4f7f\u7528Python3\u7684\u6b65\u9aa4\u5305\u62ec\u5b89\u88c5PyCharm\u3001\u5b89\u88c5Python3\u3001\u914d\u7f6e\u89e3\u91ca\u5668\u3001\u521b\u5efa\u65b0\u9879\u76ee\u3001 [&hellip;]","protected":false},"author":3,"featured_media":1057824,"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\/1057819"}],"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=1057819"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1057819\/revisions"}],"predecessor-version":[{"id":1057827,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1057819\/revisions\/1057827"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1057824"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1057819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1057819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1057819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}