{"id":927434,"date":"2024-12-26T16:09:19","date_gmt":"2024-12-26T08:09:19","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/927434.html"},"modified":"2024-12-26T16:09:20","modified_gmt":"2024-12-26T08:09:20","slug":"%e5%a6%82%e4%bd%95%e6%96%b0%e5%bb%bapython","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/927434.html","title":{"rendered":"\u5982\u4f55\u65b0\u5efapython"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25063555\/531ebfc6-b00a-4b18-910c-f293b876077f.webp\" alt=\"\u5982\u4f55\u65b0\u5efapython\" \/><\/p>\n<p><p> <strong>\u8981\u65b0\u5efaPython\u9879\u76ee\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u521b\u5efa\u4e00\u4e2a\u865a\u62df\u73af\u5883\u3001\u9009\u62e9\u4e00\u4e2a\u5408\u9002\u7684IDE\u6216\u6587\u672c\u7f16\u8f91\u5668\u3001\u8bbe\u7f6e\u9879\u76ee\u7ed3\u6784\u3001\u521d\u59cb\u5316Git\u4ed3\u5e93\u3001\u5b89\u88c5\u5fc5\u8981\u7684\u4f9d\u8d56\u5e93\u3002\u521b\u5efa\u865a\u62df\u73af\u5883\u53ef\u4ee5\u786e\u4fdd\u9879\u76ee\u7684\u4f9d\u8d56\u4e0e\u5176\u4ed6\u9879\u76ee\u9694\u79bb\u3001\u4f7f\u7528\u5408\u9002\u7684IDE\u6216\u6587\u672c\u7f16\u8f91\u5668\u6709\u52a9\u4e8e\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u521b\u5efa\u4e00\u4e2aPython\u9879\u76ee\u5e76\u4e0d\u662f\u7b80\u5355\u7684\u6587\u4ef6\u65b0\u5efa\u64cd\u4f5c\uff0c\u800c\u662f\u4e00\u4e2a\u6d89\u53ca\u591a\u4e2a\u6b65\u9aa4\u7684\u8fc7\u7a0b\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u7684\u8bf4\u660e\u548c\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u521b\u5efa\u865a\u62df\u73af\u5883<\/p>\n<\/p>\n<p><p>Python\u865a\u62df\u73af\u5883\u662f\u4e00\u4e2a\u72ec\u7acb\u7684Python\u73af\u5883\uff0c\u5141\u8bb8\u4f60\u5728\u4e0d\u5f71\u54cd\u7cfb\u7edfPython\u5b89\u88c5\u7684\u60c5\u51b5\u4e0b\u5b89\u88c5\u9879\u76ee\u4f9d\u8d56\u3002\u4f7f\u7528\u865a\u62df\u73af\u5883\u7684\u597d\u5904\u5728\u4e8e\u53ef\u4ee5\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u5e93\u51b2\u7a81\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u5b89\u88c5\u865a\u62df\u73af\u5883\u5de5\u5177<\/p>\n<\/p>\n<ul>\n<li>\u9996\u5148\uff0c\u4f60\u9700\u8981\u786e\u4fdd\u5df2\u5b89\u88c5Python\u3002\u53ef\u4ee5\u901a\u8fc7\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c<code>python --version<\/code>\u6765\u68c0\u67e5\u3002<\/li>\n<li>\u4f7f\u7528pip\u5b89\u88c5<code>virtualenv<\/code>\uff1a<code>pip install virtualenv<\/code><\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u521b\u5efa\u865a\u62df\u73af\u5883<\/p>\n<\/p>\n<ul>\n<li>\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u8fd0\u884c\uff1a<code>virtualenv venv<\/code><\/li>\n<li><code>venv<\/code>\u662f\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\uff0c\u4f60\u53ef\u4ee5\u81ea\u5b9a\u4e49\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/p>\n<\/p>\n<ul>\n<li>Windows\uff1a<code>venv\\Scripts\\activate<\/code><\/li>\n<li>macOS\u548cLinux\uff1a<code>source venv\/bin\/activate<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u6fc0\u6d3b\u540e\uff0c\u4f60\u4f1a\u770b\u5230\u547d\u4ee4\u884c\u63d0\u793a\u7b26\u524d\u9762\u51fa\u73b0\u4e00\u4e2a\u62ec\u53f7\u4e2d\u7684<code>venv<\/code>\uff0c\u8868\u793a\u865a\u62df\u73af\u5883\u5df2\u6fc0\u6d3b\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u9009\u62e9\u5408\u9002\u7684IDE\u6216\u6587\u672c\u7f16\u8f91\u5668<\/p>\n<\/p>\n<p><p>\u9009\u62e9\u5408\u9002\u7684\u5f00\u53d1\u5de5\u5177\u53ef\u4ee5\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p>PyCharm<\/p>\n<\/p>\n<ul>\n<li>PyCharm\u662fJetBr<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ns\u51fa\u54c1\u7684Python\u4e13\u7528IDE\uff0c\u63d0\u4f9b\u667a\u80fd\u4ee3\u7801\u8865\u5168\u3001\u8c03\u8bd5\u5de5\u5177\u3001\u7248\u672c\u63a7\u5236\u96c6\u6210\u7b49\u529f\u80fd\uff0c\u975e\u5e38\u9002\u5408\u4e2d\u5927\u578bPython\u9879\u76ee\u5f00\u53d1\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Visual Studio Code<\/p>\n<\/p>\n<ul>\n<li>VSCode\u662f\u4e00\u6b3e\u8f7b\u91cf\u7ea7\u4f46\u529f\u80fd\u5f3a\u5927\u7684\u6587\u672c\u7f16\u8f91\u5668\uff0c\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\u3002\u901a\u8fc7\u5b89\u88c5Python\u6269\u5c55\uff0c\u53ef\u4ee5\u83b7\u5f97\u7c7b\u4f3cIDE\u7684\u529f\u80fd\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Jupyter Notebook<\/p>\n<\/p>\n<ul>\n<li>\u9002\u5408\u6570\u636e\u5206\u6790\u548c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u9879\u76ee\uff0c\u652f\u6301\u5185\u5d4c\u56fe\u8868\u548c\u4ea4\u4e92\u5f0f\u4ee3\u7801\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u8bbe\u7f6e\u9879\u76ee\u7ed3\u6784<\/p>\n<\/p>\n<p><p>\u4e00\u4e2a\u826f\u597d\u7684\u9879\u76ee\u7ed3\u6784\u6709\u52a9\u4e8e\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u521b\u5efa\u9879\u76ee\u76ee\u5f55<\/p>\n<\/p>\n<ul>\n<li>\u5efa\u7acb\u4e00\u4e2a\u9879\u76ee\u4e3b\u76ee\u5f55\uff0c\u5e76\u5728\u5176\u4e2d\u521b\u5efa\u5b50\u76ee\u5f55\uff0c\u5982<code>src<\/code>\u3001<code>tests<\/code>\u3001<code>docs<\/code>\u7b49\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u521b\u5efa<code>README.md<\/code><\/p>\n<\/p>\n<ul>\n<li>\u8bb0\u5f55\u9879\u76ee\u7684\u57fa\u672c\u4fe1\u606f\u3001\u5b89\u88c5\u6b65\u9aa4\u3001\u4f7f\u7528\u65b9\u6cd5\u7b49\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u521d\u59cb\u5316<code>__init__.py<\/code><\/p>\n<\/p>\n<ul>\n<li>\u5728\u6bcf\u4e2aPython\u5305\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a<code>__init__.py<\/code>\u6587\u4ef6\uff0c\u4f7f\u5176\u6210\u4e3a\u4e00\u4e2aPython\u5305\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u521d\u59cb\u5316Git\u4ed3\u5e93<\/p>\n<\/p>\n<p><p>\u7248\u672c\u63a7\u5236\u662f\u8f6f\u4ef6\u5f00\u53d1\u7684\u91cd\u8981\u7ec4\u6210\u90e8\u5206\uff0cGit\u662f\u6700\u6d41\u884c\u7684\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u521d\u59cb\u5316Git\u4ed3\u5e93<\/p>\n<\/p>\n<ul>\n<li>\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u8fd0\u884c\uff1a<code>git init<\/code><\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u521b\u5efa<code>.gitignore<\/code><\/p>\n<\/p>\n<ul>\n<li>\u6dfb\u52a0\u4e0d\u9700\u8981\u7248\u672c\u63a7\u5236\u7684\u6587\u4ef6\u548c\u76ee\u5f55\uff0c\u4f8b\u5982\u865a\u62df\u73af\u5883\u76ee\u5f55\u3001\u7f16\u8bd1\u6587\u4ef6\u7b49\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u521b\u5efa\u521d\u59cb\u63d0\u4ea4<\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528<code>git add .<\/code>\u5c06\u6240\u6709\u6587\u4ef6\u6dfb\u52a0\u5230\u7248\u672c\u63a7\u5236\u4e2d\uff0c\u7136\u540e<code>git commit -m &quot;Initial commit&quot;<\/code>\u63d0\u4ea4\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u5b89\u88c5\u5fc5\u8981\u7684\u4f9d\u8d56\u5e93<\/p>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u521d\u671f\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u5b89\u88c5\u4e00\u4e9b\u5e38\u7528\u7684\u7b2c\u4e09\u65b9\u5e93\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u4f7f\u7528<code>requirements.txt<\/code><\/p>\n<\/p>\n<ul>\n<li>\u521b\u5efa\u4e00\u4e2a<code>requirements.txt<\/code>\u6587\u4ef6\uff0c\u5217\u51fa\u9879\u76ee\u4f9d\u8d56\u5e93\u53ca\u5176\u7248\u672c\u3002<\/li>\n<li>\u4f8b\u5982\uff1a\n<pre><code>numpy==1.21.0<\/p>\n<p>pandas==1.3.0<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u5b89\u88c5\u4f9d\u8d56\u5e93<\/p>\n<\/p>\n<ul>\n<li>\u5728\u6fc0\u6d3b\u7684\u865a\u62df\u73af\u5883\u4e2d\u8fd0\u884c\uff1a<code>pip install -r requirements.txt<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p><strong>\u603b\u7ed3<\/strong><\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u9ad8\u6548\u5730\u65b0\u5efa\u4e00\u4e2aPython\u9879\u76ee\uff0c\u5e76\u4e3a\u540e\u7eed\u7684\u5f00\u53d1\u5de5\u4f5c\u6253\u4e0b\u575a\u5b9e\u7684\u57fa\u7840\u3002\u4f7f\u7528\u865a\u62df\u73af\u5883\u3001\u5408\u9002\u7684IDE\u3001\u5408\u7406\u7684\u9879\u76ee\u7ed3\u6784\u4ee5\u53ca\u7248\u672c\u63a7\u5236\u5de5\u5177\uff0c\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u6301\u7eed\u5b66\u4e60\u548c\u6539\u8fdb\u8fd9\u4e9b\u5de5\u5177\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u5c06\u4f1a\u4f7f\u4f60\u7684Python\u9879\u76ee\u5f00\u53d1\u66f4\u52a0\u5f97\u5fc3\u5e94\u624b\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728\u6211\u7684\u7535\u8111\u4e0a\u5b89\u88c5Python\uff1f<\/strong><br \/>\u8981\u5728\u7535\u8111\u4e0a\u5b89\u88c5Python\uff0c\u9996\u5148\u8bbf\u95eePython\u7684\u5b98\u65b9\u7f51\u7ad9\uff08python.org\uff09\uff0c\u627e\u5230\u4e0b\u8f7d\u9875\u9762\uff0c\u9009\u62e9\u9002\u5408\u4f60\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c\u3002\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\uff0c\u786e\u4fdd\u9009\u62e9\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u8f7b\u677e\u8bbf\u95eePython\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>python --version<\/code>\u6765\u786e\u8ba4\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002<\/p>\n<p><strong>\u65b0\u624b\u5982\u4f55\u5f00\u59cb\u5b66\u4e60Python\u7f16\u7a0b\uff1f<\/strong><br \/>\u5bf9\u4e8e\u65b0\u624b\u6765\u8bf4\uff0c\u5b66\u4e60Python\u7f16\u7a0b\u53ef\u4ee5\u4ece\u57fa\u7840\u8bed\u6cd5\u5f00\u59cb\u3002\u63a8\u8350\u4f7f\u7528\u5728\u7ebf\u8bfe\u7a0b\u548c\u4e92\u52a8\u5b66\u4e60\u5e73\u53f0\uff0c\u4f8b\u5982Codecademy\u6216Coursera\uff0c\u8fd9\u4e9b\u5e73\u53f0\u63d0\u4f9b\u4e86\u7ed3\u6784\u5316\u7684\u5b66\u4e60\u8def\u5f84\u548c\u5b9e\u8df5\u9879\u76ee\u3002\u6b64\u5916\uff0c\u9605\u8bfb\u76f8\u5173\u4e66\u7c4d\uff0c\u5982\u300aPython\u7f16\u7a0b\uff1a\u4ece\u5165\u95e8\u5230\u5b9e\u8df5\u300b\uff0c\u4e5f\u80fd\u5e2e\u52a9\u4f60\u7406\u89e3\u57fa\u672c\u6982\u5ff5\u548c\u5e94\u7528\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u521b\u5efa\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\uff1f<\/strong><br \/>\u521b\u5efa\u4f60\u7684\u7b2c\u4e00\u4e2aPython\u7a0b\u5e8f\u975e\u5e38\u7b80\u5355\u3002\u6253\u5f00\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u6216IDE\uff08\u5982PyCharm\u6216Visual Studio Code\uff09\uff0c\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6\uff0c\u8f93\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<code>print(&quot;Hello, World!&quot;)<\/code>\u3002\u4fdd\u5b58\u6587\u4ef6\u4e3a<code>hello.py<\/code>\u3002\u63a5\u7740\u5728\u547d\u4ee4\u884c\u4e2d\u5bfc\u822a\u5230\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\uff0c\u5e76\u8f93\u5165<code>python hello.py<\/code>\uff0c\u4f60\u5c06\u770b\u5230\u8f93\u51fa\u7684\u201cHello, World!\u201d\u4fe1\u606f\uff0c\u8fd9\u6807\u5fd7\u7740\u4f60\u6210\u529f\u521b\u5efa\u4e86\u7b2c\u4e00\u4e2aPython\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u65b0\u5efaPython\u9879\u76ee\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u521b\u5efa\u4e00\u4e2a\u865a\u62df\u73af\u5883\u3001\u9009\u62e9\u4e00\u4e2a\u5408\u9002\u7684IDE\u6216\u6587\u672c\u7f16\u8f91\u5668\u3001\u8bbe\u7f6e\u9879\u76ee\u7ed3\u6784\u3001\u521d\u59cb\u5316Gi [&hellip;]","protected":false},"author":3,"featured_media":927437,"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\/927434"}],"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=927434"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/927434\/revisions"}],"predecessor-version":[{"id":927438,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/927434\/revisions\/927438"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/927437"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=927434"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=927434"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=927434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}