{"id":994445,"date":"2024-12-27T08:55:29","date_gmt":"2024-12-27T00:55:29","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/994445.html"},"modified":"2024-12-27T08:55:32","modified_gmt":"2024-12-27T00:55:32","slug":"python%e5%ae%89%e8%a3%85%e5%ae%8c%e5%a6%82%e4%bd%95%e5%ba%94%e7%94%a8","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/994445.html","title":{"rendered":"python\u5b89\u88c5\u5b8c\u5982\u4f55\u5e94\u7528"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25071433\/7a55f3e3-c824-4c11-989e-e40583f8dbc9.webp\" alt=\"python\u5b89\u88c5\u5b8c\u5982\u4f55\u5e94\u7528\" \/><\/p>\n<p><p> <strong>\u5b89\u88c5\u5b8cPython\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u8fd0\u884cPython\u811a\u672c\u3001\u4f7f\u7528Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u3001\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u8fdb\u884c\u5f00\u53d1\u3001\u5b89\u88c5\u548c\u4f7f\u7528Python\u5e93\u3002<\/strong>\u5176\u4e2d\uff0c\u4f7f\u7528\u547d\u4ee4\u884c\u8fd0\u884cPython\u811a\u672c\u662f\u6700\u57fa\u672c\u7684\u5e94\u7528\u65b9\u5f0f\uff0c\u521d\u5b66\u8005\u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684\u547d\u4ee4\u884c\u64cd\u4f5c\u6765\u6267\u884cPython\u7a0b\u5e8f\u3002\u5728\u6b64\u57fa\u7840\u4e0a\uff0c\u9009\u62e9\u5408\u9002\u7684IDE\uff0c\u5982PyCharm\u6216VS Code\uff0c\u53ef\u4ee5\u6781\u5927\u5730\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u548c\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u547d\u4ee4\u884c\u8fd0\u884cPython\u811a\u672c<\/p>\n<\/p>\n<p><p>\u5728\u5b89\u88c5\u5b8cPython\u540e\uff0c\u6700\u76f4\u63a5\u7684\u5e94\u7528\u65b9\u5f0f\u662f\u901a\u8fc7\u547d\u4ee4\u884c\u8fd0\u884cPython\u811a\u672c\u3002\u4f60\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\uff08Windows\u7684\u547d\u4ee4\u63d0\u793a\u7b26\u6216Linux\/Mac\u7684\u7ec8\u7aef\uff09\u4e2d\u8f93\u5165<code>python<\/code>\u547d\u4ee4\u6765\u542f\u52a8Python\u89e3\u91ca\u5668\uff0c\u6216\u8005\u901a\u8fc7<code>python scriptname.py<\/code>\u547d\u4ee4\u6765\u8fd0\u884cPython\u811a\u672c\u6587\u4ef6\u3002\u6b64\u65b9\u6cd5\u9002\u7528\u4e8e\u5feb\u901f\u6d4b\u8bd5\u548c\u8fd0\u884c\u5c0f\u578b\u7a0b\u5e8f\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u3002<\/li>\n<li>\u8f93\u5165<code>python<\/code>\u4ee5\u542f\u52a8Python\u89e3\u91ca\u5668\u8fdb\u884c\u4ea4\u4e92\u5f0f\u7f16\u7a0b\u3002<\/li>\n<li>\u8f93\u5165<code>python scriptname.py<\/code>\u4ee5\u8fd0\u884c\u6307\u5b9a\u7684Python\u811a\u672c\u3002<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u4f7f\u7528Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668<\/p>\n<\/p>\n<p><p>Python\u81ea\u5e26\u7684\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u662f\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684\u5de5\u5177\uff0c\u7279\u522b\u9002\u5408\u7528\u4e8e\u6d4b\u8bd5\u4ee3\u7801\u7247\u6bb5\u548c\u5b66\u4e60Python\u8bed\u6cd5\u3002\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\uff08\u89c6\u5b89\u88c5\u7684Python\u7248\u672c\u800c\u5b9a\uff09\u5373\u53ef\u8fdb\u5165\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u3002\u4f60\u53ef\u4ee5\u5728\u5176\u4e2d\u76f4\u63a5\u8f93\u5165Python\u4ee3\u7801\uff0c\u56de\u8f66\u540e\u7acb\u5373\u770b\u5230\u6267\u884c\u7ed3\u679c\u3002\u8fd9\u5bf9\u4e8e\u5b66\u4e60\u548c\u8c03\u8bd5\u4ee3\u7801\u975e\u5e38\u6709\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u9009\u62e9\u5408\u9002\u7684\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09<\/p>\n<\/p>\n<p><p>\u4f7f\u7528IDE\u8fdb\u884cPython\u5f00\u53d1\uff0c\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u4f60\u7684\u5f00\u53d1\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684Python IDE\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>PyCharm<\/strong>\uff1aPyCharm\u662f\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684Python IDE\uff0c\u63d0\u4f9b\u4ee3\u7801\u8865\u5168\u3001\u8c03\u8bd5\u3001\u6d4b\u8bd5\u3001\u7248\u672c\u63a7\u5236\u7b49\u529f\u80fd\u3002\u9002\u7528\u4e8e\u5927\u578b\u9879\u76ee\u5f00\u53d1\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>VS Code<\/strong>\uff1aVisual Studio Code\u662f\u4e00\u6b3e\u8f7b\u91cf\u7ea7\u7684\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u5b89\u88c5Python\u6269\u5c55\u540e\uff0c\u53ef\u4ee5\u63d0\u4f9b\u7c7b\u4f3cPyCharm\u7684\u529f\u80fd\uff0c\u9002\u5408\u4e8e\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\u7684\u5f00\u53d1\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>Jupyter Notebook<\/strong>\uff1a\u7279\u522b\u9002\u5408\u6570\u636e\u79d1\u5b66\u548c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u9886\u57df\u7684\u5f00\u53d1\uff0c\u652f\u6301\u4ea4\u4e92\u5f0f\u6570\u636e\u5206\u6790\u548c\u53ef\u89c6\u5316\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4f7f\u7528IDE\u65f6\uff0c\u4f60\u53ef\u4ee5\u521b\u5efa\u9879\u76ee\u3001\u7f16\u8f91\u4ee3\u7801\u3001\u8fd0\u884c\u548c\u8c03\u8bd5\u7a0b\u5e8f\u3002IDE\u901a\u5e38\u63d0\u4f9b\u56fe\u5f62\u5316\u7684\u7528\u6237\u754c\u9762\uff0c\u4f7f\u5f97\u4ee3\u7801\u7684\u7f16\u5199\u548c\u7ba1\u7406\u66f4\u52a0\u65b9\u4fbf\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u5b89\u88c5\u548c\u4f7f\u7528Python\u5e93<\/p>\n<\/p>\n<p><p>Python\u62e5\u6709\u4e30\u5bcc\u7684\u7b2c\u4e09\u65b9\u5e93\uff0c\u53ef\u4ee5\u901a\u8fc7Python\u7684\u5305\u7ba1\u7406\u5de5\u5177<code>pip<\/code>\u8fdb\u884c\u5b89\u88c5\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>pip install numpy<\/code>\u53ef\u4ee5\u5b89\u88c5\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u7684NumPy\u5e93\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u5728Python\u811a\u672c\u4e2d\u4f7f\u7528<code>import<\/code>\u8bed\u53e5\u6765\u5f15\u7528\u8fd9\u4e9b\u5e93\uff0c\u4ece\u800c\u6269\u5c55Python\u7684\u529f\u80fd\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u5e93<\/strong>\uff1a\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528<code>pip install libraryname<\/code>\u547d\u4ee4\u6765\u5b89\u88c5\u6240\u9700\u7684\u7b2c\u4e09\u65b9\u5e93\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u5e93<\/strong>\uff1a\u5728Python\u4ee3\u7801\u4e2d\u4f7f\u7528<code>import libraryname<\/code>\u8bed\u53e5\u6765\u5bfc\u5165\u5e93\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u8c03\u7528\u5e93\u4e2d\u7684\u51fd\u6570\u548c\u7c7b\u6765\u5b9e\u73b0\u7279\u5b9a\u529f\u80fd\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u7f16\u5199\u548c\u8fd0\u884cPython\u7a0b\u5e8f<\/p>\n<\/p>\n<p><p>\u5728\u5b89\u88c5\u548c\u914d\u7f6e\u597d\u5f00\u53d1\u73af\u5883\u540e\uff0c\u4f60\u53ef\u4ee5\u5f00\u59cb\u7f16\u5199Python\u7a0b\u5e8f\u3002Python\u7684\u8bed\u6cd5\u7b80\u6d01\u6613\u8bfb\uff0c\u975e\u5e38\u9002\u5408\u521d\u5b66\u8005\u3002\u4ee5\u4e0b\u662f\u7f16\u5199\u548c\u8fd0\u884cPython\u7a0b\u5e8f\u7684\u4e00\u822c\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u7f16\u5199\u4ee3\u7801<\/strong>\uff1a\u5728\u6587\u672c\u7f16\u8f91\u5668\u6216IDE\u4e2d\u7f16\u5199Python\u4ee3\u7801\uff0c\u4fdd\u5b58\u4e3a<code>.py<\/code>\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884c\u7a0b\u5e8f<\/strong>\uff1a\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528<code>python scriptname.py<\/code>\u547d\u4ee4\u8fd0\u884cPython\u7a0b\u5e8f\uff0c\u6216\u5728IDE\u4e2d\u4f7f\u7528\u201c\u8fd0\u884c\u201d\u6309\u94ae\u6267\u884c\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8c03\u8bd5\u4ee3\u7801<\/strong>\uff1a\u5982\u679c\u7a0b\u5e8f\u6709\u9519\u8bef\uff0c\u4f7f\u7528IDE\u63d0\u4f9b\u7684\u8c03\u8bd5\u5de5\u5177\u8fdb\u884c\u8c03\u8bd5\uff0c\u6216\u8005\u5728\u4ee3\u7801\u4e2d\u52a0\u5165<code>print<\/code>\u8bed\u53e5\u4ee5\u67e5\u770b\u53d8\u91cf\u503c\u548c\u7a0b\u5e8f\u6d41\u7a0b\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u51e0\u79cd\u65b9\u5f0f\uff0c\u4f60\u53ef\u4ee5\u5145\u5206\u5229\u7528Python\u8fdb\u884c\u5404\u79cd\u7c7b\u578b\u7684\u5f00\u53d1\uff0c\u4ece\u7b80\u5355\u7684\u811a\u672c\u5230\u590d\u6742\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u65e0\u8bba\u662f\u8fdb\u884c\u6570\u636e\u5206\u6790\u3001Web\u5f00\u53d1\u8fd8\u662f\u81ea\u52a8\u5316\u4efb\u52a1\uff0cPython\u90fd\u80fd\u4e3a\u4f60\u63d0\u4f9b\u5f3a\u5927\u7684\u652f\u6301\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u786e\u8ba4Python\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1f<\/strong><br \/>\u5728\u5b89\u88c5\u5b8cPython\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u786e\u8ba4\u5176\u662f\u5426\u6210\u529f\u5b89\u88c5\u3002\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08Windows\uff09\u6216\u7ec8\u7aef\uff08Mac\/Linux\uff09\uff0c\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\uff0c\u5982\u679c\u663e\u793a\u51faPython\u7684\u7248\u672c\u53f7\uff0c\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<p><strong>\u6211\u8be5\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684IDE\u6765\u5f00\u53d1Python\u5e94\u7528\uff1f<\/strong><br \/>\u9009\u62e9\u5408\u9002\u7684\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u53ef\u4ee5\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u3002\u5e38\u89c1\u7684Python IDE\u5305\u62ecPyCharm\u3001Visual Studio Code\u548cJupyter Notebook\u3002\u6839\u636e\u4e2a\u4eba\u9700\u6c42\uff0cPyCharm\u9002\u5408\u5927\u578b\u9879\u76ee\uff0cVisual Studio Code\u9002\u5408\u8f7b\u91cf\u7ea7\u7f16\u8f91\uff0c\u800cJupyter Notebook\u9002\u5408\u6570\u636e\u5206\u6790\u548c\u53ef\u89c6\u5316\u3002<\/p>\n<p><strong>\u5b89\u88c5\u5b8cPython\u540e\uff0c\u5982\u4f55\u5f00\u59cb\u5199\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\uff1f<\/strong><br \/>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u6587\u672c\u7f16\u8f91\u5668\u7f16\u5199Python\u4ee3\u7801\u3002\u6253\u5f00IDE\u6216\u6587\u672c\u7f16\u8f91\u5668\uff0c\u8f93\u5165\u7b80\u5355\u7684\u6253\u5370\u8bed\u53e5\uff0c\u4f8b\u5982<code>print(&quot;Hello, World!&quot;)<\/code>\uff0c\u7136\u540e\u4fdd\u5b58\u6587\u4ef6\u4e3a<code>.py<\/code>\u683c\u5f0f\u3002\u5728\u547d\u4ee4\u884c\u4e2d\uff0c\u4f7f\u7528<code>python \u6587\u4ef6\u540d.py<\/code>\u547d\u4ee4\u8fd0\u884c\u8be5\u7a0b\u5e8f\uff0c\u67e5\u770b\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5b89\u88c5\u5b8cPython\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u8fd0\u884cPython\u811a\u672c\u3001\u4f7f\u7528Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u3001\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE [&hellip;]","protected":false},"author":3,"featured_media":994455,"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\/994445"}],"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=994445"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/994445\/revisions"}],"predecessor-version":[{"id":994460,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/994445\/revisions\/994460"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/994455"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=994445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=994445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=994445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}