{"id":1084187,"date":"2025-01-08T13:05:00","date_gmt":"2025-01-08T05:05:00","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1084187.html"},"modified":"2025-01-08T13:05:03","modified_gmt":"2025-01-08T05:05:03","slug":"%e5%a6%82%e4%bd%95%e6%8a%8apython%e7%9a%84console%e8%b0%83%e5%87%ba%e6%9d%a5-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1084187.html","title":{"rendered":"\u5982\u4f55\u628apython\u7684console\u8c03\u51fa\u6765"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24194640\/859a0939-460d-46b6-9dbf-eb01d4fd8d91.webp\" alt=\"\u5982\u4f55\u628apython\u7684console\u8c03\u51fa\u6765\" \/><\/p>\n<p><p> <strong>\u8981\u628aPython\u7684console\u8c03\u51fa\u6765\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\u3001\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165 <code>python<\/code> \u6216 <code>python3<\/code>\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u6216\u4ee3\u7801\u7f16\u8f91\u5668\u6253\u5f00Python\u63a7\u5236\u53f0\u3001\u5728Jupyter Notebook\u4e2d\u8fd0\u884c\u4ee3\u7801<\/strong>\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\u6765\u8c03\u51faPython\u7684\u63a7\u5236\u53f0\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165 <code>python<\/code> \u6216 <code>python3<\/code><\/h3>\n<\/p>\n<p><p>\u5728\u5927\u591a\u6570\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u4f60\u53ef\u4ee5\u76f4\u63a5\u5728\u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u8f93\u5165 <code>python<\/code> \u6216 <code>python3<\/code> \u6765\u8c03\u51faPython\u7684\u63a7\u5236\u53f0\u3002<\/p>\n<\/p>\n<p><h4>1. Windows \u64cd\u4f5c\u7cfb\u7edf<\/h4>\n<\/p>\n<ul>\n<li>\u9996\u5148\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08Command Prompt\uff09\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u6309\u4e0b <code>Win + R<\/code> \u6253\u5f00\u8fd0\u884c\u7a97\u53e3\uff0c\u7136\u540e\u8f93\u5165 <code>cmd<\/code> \u5e76\u6309\u4e0b\u56de\u8f66\u6765\u6253\u5f00\u3002<\/li>\n<li>\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165 <code>python<\/code> \u6216 <code>python3<\/code>\uff0c\u7136\u540e\u6309\u4e0b\u56de\u8f66\u952e\u3002<\/li>\n<li>\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u4f60\u5c06\u4f1a\u770b\u5230\u4e00\u4e2a\u7c7b\u4f3c\u4e8e <code>&gt;&gt;&gt;<\/code> \u7684\u63d0\u793a\u7b26\uff0c\u8fd9\u8868\u793a\u4f60\u5df2\u7ecf\u8fdb\u5165\u4e86Python\u7684\u4ea4\u4e92\u6a21\u5f0f\u3002<\/li>\n<\/ul>\n<p><h4>2. macOS \u548c Linux \u64cd\u4f5c\u7cfb\u7edf<\/h4>\n<\/p>\n<ul>\n<li>\u6253\u5f00\u7ec8\u7aef\uff08Terminal\uff09\u3002\u5728macOS\u4e2d\uff0c\u4f60\u53ef\u4ee5\u6309\u4e0b <code>Command + Space<\/code> \u6253\u5f00Spotlight\u641c\u7d22\uff0c\u7136\u540e\u8f93\u5165 <code>Terminal<\/code> \u5e76\u6309\u4e0b\u56de\u8f66\u3002\u5728Linux\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4ece\u5e94\u7528\u7a0b\u5e8f\u83dc\u5355\u4e2d\u627e\u5230\u5e76\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li>\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165 <code>python<\/code> \u6216 <code>python3<\/code>\uff0c\u7136\u540e\u6309\u4e0b\u56de\u8f66\u952e\u3002<\/li>\n<li>\u4f60\u5c06\u770b\u5230\u4e00\u4e2a\u7c7b\u4f3c\u4e8e <code>&gt;&gt;&gt;<\/code> \u7684\u63d0\u793a\u7b26\uff0c\u8fd9\u8868\u793a\u4f60\u5df2\u7ecf\u8fdb\u5165\u4e86Python\u7684\u4ea4\u4e92\u6a21\u5f0f\u3002<\/li>\n<\/ul>\n<p><h3>\u4e8c\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u6216\u4ee3\u7801\u7f16\u8f91\u5668\u6253\u5f00Python\u63a7\u5236\u53f0<\/h3>\n<\/p>\n<p><p>\u8bb8\u591a\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u548c\u4ee3\u7801\u7f16\u8f91\u5668\u90fd\u63d0\u4f9b\u4e86\u5185\u7f6e\u7684Python\u63a7\u5236\u53f0\uff0c\u4f7f\u5f97\u6211\u4eec\u53ef\u4ee5\u5728\u7f16\u5199\u4ee3\u7801\u7684\u540c\u65f6\uff0c\u8f7b\u677e\u5730\u8fdb\u884c\u8c03\u8bd5\u548c\u6d4b\u8bd5\u3002<\/p>\n<\/p>\n<p><h4>1. \u4f7f\u7528PyCharm<\/h4>\n<\/p>\n<ul>\n<li>\u6253\u5f00PyCharm\u5e76\u521b\u5efa\u6216\u6253\u5f00\u4e00\u4e2aPython\u9879\u76ee\u3002<\/li>\n<li>\u70b9\u51fb\u53f3\u4e0b\u89d2\u7684\u201cPython Console\u201d\u6309\u94ae\uff0c\u8fd9\u5c06\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u63a7\u5236\u53f0\u7a97\u53e3\u3002<\/li>\n<li>\u5728\u65b0\u7684\u63a7\u5236\u53f0\u7a97\u53e3\u4e2d\uff0c\u4f60\u53ef\u4ee5\u770b\u5230\u4e00\u4e2a\u7c7b\u4f3c\u4e8e <code>&gt;&gt;&gt;<\/code> \u7684\u63d0\u793a\u7b26\uff0c\u8fd9\u8868\u793a\u4f60\u5df2\u7ecf\u8fdb\u5165\u4e86Python\u7684\u4ea4\u4e92\u6a21\u5f0f\u3002<\/li>\n<\/ul>\n<p><h4>2. \u4f7f\u7528Visual Studio Code<\/h4>\n<\/p>\n<ul>\n<li>\u6253\u5f00Visual Studio Code\u5e76\u521b\u5efa\u6216\u6253\u5f00\u4e00\u4e2aPython\u6587\u4ef6\u3002<\/li>\n<li>\u70b9\u51fb\u5e95\u90e8\u5de5\u5177\u680f\u4e2d\u7684\u7ec8\u7aef\u56fe\u6807\uff0c\u9009\u62e9\u201c\u65b0\u5efa\u7ec8\u7aef\u201d\u9009\u9879\u3002<\/li>\n<li>\u5728\u7ec8\u7aef\u7a97\u53e3\u4e2d\u8f93\u5165 <code>python<\/code> \u6216 <code>python3<\/code>\uff0c\u7136\u540e\u6309\u4e0b\u56de\u8f66\u952e\u3002<\/li>\n<li>\u4f60\u5c06\u770b\u5230\u4e00\u4e2a\u7c7b\u4f3c\u4e8e <code>&gt;&gt;&gt;<\/code> \u7684\u63d0\u793a\u7b26\uff0c\u8fd9\u8868\u793a\u4f60\u5df2\u7ecf\u8fdb\u5165\u4e86Python\u7684\u4ea4\u4e92\u6a21\u5f0f\u3002<\/li>\n<\/ul>\n<p><h3>\u4e09\u3001\u5728Jupyter Notebook\u4e2d\u8fd0\u884c\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>Jupyter Notebook\u662f\u4e00\u6b3e\u975e\u5e38\u6d41\u884c\u7684\u4ea4\u4e92\u5f0f\u8ba1\u7b97\u73af\u5883\uff0c\u5e7f\u6cdb\u7528\u4e8e\u6570\u636e\u79d1\u5b66\u548c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u9886\u57df\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7Jupyter Notebook\u6765\u8fd0\u884cPython\u4ee3\u7801\uff0c\u5e76\u67e5\u770b\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5Jupyter Notebook<\/h4>\n<\/p>\n<ul>\n<li>\n<p>\u9996\u5148\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u548cpip\uff08Python\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff09\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5Jupyter Notebook\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install jupyter<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><h4>2. \u542f\u52a8Jupyter Notebook<\/h4>\n<\/p>\n<ul>\n<li>\n<p>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u542f\u52a8Jupyter Notebook\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">jupyter notebook<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u8fd9\u5c06\u4f1a\u5728\u4f60\u7684\u9ed8\u8ba4\u6d4f\u89c8\u5668\u4e2d\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u6807\u7b7e\u9875\uff0c\u5e76\u663e\u793aJupyter Notebook\u7684\u7528\u6237\u754c\u9762\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h4>3. \u521b\u5efa\u5e76\u8fd0\u884cNotebook<\/h4>\n<\/p>\n<ul>\n<li>\u5728Jupyter Notebook\u7684\u7528\u6237\u754c\u9762\u4e2d\uff0c\u70b9\u51fb\u201c\u65b0\u5efa\u201d\u6309\u94ae\uff0c\u7136\u540e\u9009\u62e9\u201cPython 3\u201d\u3002<\/li>\n<li>\u8fd9\u5c06\u4f1a\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Notebook\u3002\u5728\u65b0\u7684Notebook\u4e2d\uff0c\u4f60\u53ef\u4ee5\u7f16\u5199\u5e76\u8fd0\u884cPython\u4ee3\u7801\u3002<\/li>\n<li>\u6bcf\u4e2a\u4ee3\u7801\u5355\u5143\u683c\u90fd\u6709\u4e00\u4e2a\u201c\u8fd0\u884c\u201d\u6309\u94ae\uff0c\u70b9\u51fb\u5b83\u53ef\u4ee5\u8fd0\u884c\u8be5\u5355\u5143\u683c\u4e2d\u7684\u4ee3\u7801\uff0c\u5e76\u5728\u4e0b\u65b9\u663e\u793a\u8f93\u51fa\u7ed3\u679c\u3002<\/li>\n<\/ul>\n<p><h3>\u7ed3\u8bba<\/h3>\n<\/p>\n<p><p>\u65e0\u8bba\u4f60\u662f\u521d\u5b66\u8005\u8fd8\u662f\u6709\u7ecf\u9a8c\u7684\u5f00\u53d1\u8005\uff0c\u4e86\u89e3\u5982\u4f55\u8c03\u51faPython\u7684\u63a7\u5236\u53f0\u90fd\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u901a\u8fc7\u547d\u4ee4\u884c\u3001\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3001\u4ee3\u7801\u7f16\u8f91\u5668\u548cJupyter Notebook\uff0c\u4f60\u53ef\u4ee5\u8f7b\u677e\u5730\u8fdb\u5165Python\u7684\u4ea4\u4e92\u6a21\u5f0f\uff0c\u8fdb\u884c\u4ee3\u7801\u8c03\u8bd5\u3001\u6d4b\u8bd5\u548c\u5b9e\u9a8c\u3002\u5e0c\u671b\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u4f60\u80fd\u591f\u5feb\u901f\u4e0a\u624b\u5e76\u6109\u5feb\u5730\u4f7f\u7528Python\u8fdb\u884c\u5f00\u53d1\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528Anaconda\u7684Spyder<\/h3>\n<\/p>\n<p><p>Anaconda\u662f\u4e00\u6b3e\u5e7f\u53d7\u6b22\u8fce\u7684\u6570\u636e\u79d1\u5b66\u5e73\u53f0\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u8bb8\u591a\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u5206\u6790\u7684\u5de5\u5177\u3002Spyder\u662fAnaconda\u5185\u7f6e\u7684\u4e00\u6b3e\u5f3a\u5927\u7684Python\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff0c\u975e\u5e38\u9002\u5408\u6570\u636e\u79d1\u5b66\u5bb6\u548c\u7814\u7a76\u4eba\u5458\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5Anaconda<\/h4>\n<\/p>\n<ul>\n<li>\u9996\u5148\u8bbf\u95eeAnaconda\u5b98\u7f51\uff08<a href=\"https:\/\/www.anaconda.com\/%EF%BC%89%EF%BC%8C%E4%B8%8B%E8%BD%BD%E9%80%82%E7%94%A8%E4%BA%8E%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%82\">https:\/\/www.anaconda.com\/\uff09\uff0c\u4e0b\u8f7d\u9002\u7528\u4e8e\u4f60\u64cd\u4f5c\u7cfb\u7edf\u7684\u5b89\u88c5\u5305\u3002<\/a><\/li>\n<li>\u6839\u636e\u5b89\u88c5\u5411\u5bfc\u5b8c\u6210Anaconda\u7684\u5b89\u88c5\u8fc7\u7a0b\u3002<\/li>\n<\/ul>\n<p><h4>2. \u542f\u52a8Spyder<\/h4>\n<\/p>\n<ul>\n<li>\u6253\u5f00Anaconda Navigator\uff0c\u8fd9\u662fAnaconda\u7684\u56fe\u5f62\u7528\u6237\u754c\u9762\u3002<\/li>\n<li>\u5728Anaconda Navigator\u4e2d\uff0c\u4f60\u4f1a\u770b\u5230\u8bb8\u591a\u53ef\u7528\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u627e\u5230\u5e76\u70b9\u51fb\u201cSpyder\u201d\u56fe\u6807\uff0c\u8fd9\u5c06\u542f\u52a8Spyder IDE\u3002<\/li>\n<li>\u5728Spyder\u4e2d\uff0c\u4f60\u4f1a\u770b\u5230\u4e00\u4e2a\u7c7b\u4f3c\u4e8e <code>&gt;&gt;&gt;<\/code> \u7684\u63d0\u793a\u7b26\uff0c\u8fd9\u8868\u793a\u4f60\u5df2\u7ecf\u8fdb\u5165\u4e86Python\u7684\u4ea4\u4e92\u6a21\u5f0f\u3002<\/li>\n<\/ul>\n<p><h3>\u4e94\u3001\u4f7f\u7528IPython<\/h3>\n<\/p>\n<p><p>IPython\u662f\u4e00\u6b3e\u589e\u5f3a\u578b\u7684Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff0c\u63d0\u4f9b\u4e86\u8bb8\u591a\u989d\u5916\u7684\u529f\u80fd\uff0c\u5982\u8bed\u6cd5\u9ad8\u4eae\u3001\u81ea\u52a8\u8865\u5168\u548c\u66f4\u5f3a\u5927\u7684\u8c03\u8bd5\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5IPython<\/h4>\n<\/p>\n<ul>\n<li>\n<p>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5IPython\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install ipython<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><h4>2. \u542f\u52a8IPython<\/h4>\n<\/p>\n<ul>\n<li>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165 <code>ipython<\/code>\uff0c\u7136\u540e\u6309\u4e0b\u56de\u8f66\u952e\u3002<\/li>\n<li>\u4f60\u5c06\u770b\u5230\u4e00\u4e2a\u7c7b\u4f3c\u4e8e <code>In [1]:<\/code> \u7684\u63d0\u793a\u7b26\uff0c\u8fd9\u8868\u793a\u4f60\u5df2\u7ecf\u8fdb\u5165\u4e86IPython\u7684\u4ea4\u4e92\u6a21\u5f0f\u3002<\/li>\n<\/ul>\n<p><h3>\u516d\u3001\u4f7f\u7528\u5728\u7ebfPython\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u4e0d\u60f3\u5728\u672c\u5730\u5b89\u88c5\u4efb\u4f55\u8f6f\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u5728\u7ebfPython\u89e3\u91ca\u5668\u6765\u8fd0\u884cPython\u4ee3\u7801\u3002\u8bb8\u591a\u7f51\u7ad9\u63d0\u4f9b\u4e86\u514d\u8d39\u7684\u5728\u7ebfPython\u89e3\u91ca\u5668\uff0c\u5982Repl.it\u3001Google Colab\u548cKaggle\u3002<\/p>\n<\/p>\n<p><h4>1. \u4f7f\u7528Repl.it<\/h4>\n<\/p>\n<ul>\n<li>\u8bbf\u95eeRepl.it\uff08<a href=\"https:\/\/repl.it\/~%EF%BC%89%E5%B9%B6%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E6%96%B0%E7%9A%84Python%E9%A1%B9%E7%9B%AE%E3%80%82\">https:\/\/repl.it\/~\uff09\u5e76\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python\u9879\u76ee\u3002<\/a><\/li>\n<li>\u5728\u9879\u76ee\u9875\u9762\u4e2d\uff0c\u4f60\u4f1a\u770b\u5230\u4e00\u4e2a\u4ee3\u7801\u7f16\u8f91\u5668\u548c\u4e00\u4e2a\u63a7\u5236\u53f0\u7a97\u53e3\u3002\u4f60\u53ef\u4ee5\u5728\u4ee3\u7801\u7f16\u8f91\u5668\u4e2d\u7f16\u5199\u4ee3\u7801\uff0c\u5e76\u70b9\u51fb\u201c\u8fd0\u884c\u201d\u6309\u94ae\u6765\u8fd0\u884c\u4ee3\u7801\u3002<\/li>\n<li>\u8f93\u51fa\u7ed3\u679c\u5c06\u663e\u793a\u5728\u63a7\u5236\u53f0\u7a97\u53e3\u4e2d\u3002<\/li>\n<\/ul>\n<p><h4>2. \u4f7f\u7528Google Colab<\/h4>\n<\/p>\n<ul>\n<li>\u8bbf\u95eeGoogle Colab\uff08<a href=\"https:\/\/colab.research.google.com\/%EF%BC%89%E5%B9%B6%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E6%96%B0%E7%9A%84Notebook%E3%80%82\">https:\/\/colab.research.google.com\/\uff09\u5e76\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Notebook\u3002<\/a><\/li>\n<li>\u5728\u65b0\u7684Notebook\u4e2d\uff0c\u4f60\u53ef\u4ee5\u7f16\u5199\u5e76\u8fd0\u884cPython\u4ee3\u7801\uff0c\u7c7b\u4f3c\u4e8e\u5728Jupyter Notebook\u4e2d\u64cd\u4f5c\u3002<\/li>\n<li>\u6bcf\u4e2a\u4ee3\u7801\u5355\u5143\u683c\u90fd\u6709\u4e00\u4e2a\u201c\u8fd0\u884c\u201d\u6309\u94ae\uff0c\u70b9\u51fb\u5b83\u53ef\u4ee5\u8fd0\u884c\u8be5\u5355\u5143\u683c\u4e2d\u7684\u4ee3\u7801\uff0c\u5e76\u5728\u4e0b\u65b9\u663e\u793a\u8f93\u51fa\u7ed3\u679c\u3002<\/li>\n<\/ul>\n<p><h3>\u4e03\u3001\u4f7f\u7528Python\u811a\u672c\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u5728\u4ea4\u4e92\u6a21\u5f0f\u4e0b\u8fd0\u884c\u4ee3\u7801\u5916\uff0c\u4f60\u8fd8\u53ef\u4ee5\u5c06Python\u4ee3\u7801\u5199\u5165\u4e00\u4e2a\u811a\u672c\u6587\u4ef6\uff0c\u5e76\u901a\u8fc7\u547d\u4ee4\u884c\u8fd0\u884c\u8be5\u811a\u672c\u3002<\/p>\n<\/p>\n<p><h4>1. \u521b\u5efaPython\u811a\u672c\u6587\u4ef6<\/h4>\n<\/p>\n<ul>\n<li>\u4f7f\u7528\u4f60\u559c\u6b22\u7684\u4ee3\u7801\u7f16\u8f91\u5668\uff08\u5982Notepad++\u3001Sublime Text\u6216Visual Studio Code\uff09\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\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\u3002<\/li>\n<\/ul>\n<p><h4>2. \u7f16\u5199\u4ee3\u7801<\/h4>\n<\/p>\n<ul>\n<li>\n<p>\u5728 <code>hello.py<\/code> \u6587\u4ef6\u4e2d\u7f16\u5199Python\u4ee3\u7801\u3002\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<\/li>\n<\/ul>\n<p><h4>3. \u8fd0\u884cPython\u811a\u672c<\/h4>\n<\/p>\n<ul>\n<li>\n<p>\u6253\u5f00\u547d\u4ee4\u884c\u7a97\u53e3\uff0c\u5bfc\u822a\u5230\u5305\u542b <code>hello.py<\/code> \u6587\u4ef6\u7684\u76ee\u5f55\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u8fd0\u884cPython\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u4f60\u5c06\u770b\u5230\u8f93\u51fa <code>Hello, World!<\/code> \u663e\u793a\u5728\u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h3>\u516b\u3001\u4f7f\u7528Python\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\u7ba1\u7406\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u51b2\u7a81\u3002<\/p>\n<\/p>\n<p><h4>1. \u521b\u5efa\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<ul>\n<li>\n<p>\u6253\u5f00\u547d\u4ee4\u884c\u7a97\u53e3\uff0c\u5bfc\u822a\u5230\u4f60\u7684\u9879\u76ee\u76ee\u5f55\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5176\u4e2d\uff0c<code>myenv<\/code> \u662f\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8fdb\u884c\u66f4\u6539\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h4>2. \u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<ul>\n<li>\n<p>\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\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<\/li>\n<li>\n<p>\u5728macOS\u548cLinux\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\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<\/li>\n<li>\n<p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u4f60\u5c06\u770b\u5230\u547d\u4ee4\u63d0\u793a\u7b26\u524d\u9762\u51fa\u73b0\u4e86\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\uff0c\u4f8b\u5982 <code>(myenv)<\/code>\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h4>3. \u5b89\u88c5\u4f9d\u8d56\u5305<\/h4>\n<\/p>\n<ul>\n<li>\n<p>\u5728\u865a\u62df\u73af\u5883\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 <code>pip<\/code> \u6765\u5b89\u88c5\u9879\u76ee\u6240\u9700\u7684\u4f9d\u8d56\u5305\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install numpy pandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><h4>4. \u8fd0\u884cPython\u4ee3\u7801<\/h4>\n<\/p>\n<ul>\n<li>\u5728\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u4f60\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165 <code>python<\/code> \u6216 <code>python3<\/code> \u6765\u8c03\u51faPython\u7684\u63a7\u5236\u53f0\u3002<\/li>\n<\/ul>\n<p><h3>\u7ed3\u8bba<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u4f60\u5df2\u7ecf\u4e86\u89e3\u4e86\u591a\u79cd\u65b9\u6cd5\u6765\u8c03\u51faPython\u7684\u63a7\u5236\u53f0\u3002\u65e0\u8bba\u662f\u901a\u8fc7\u547d\u4ee4\u884c\u3001\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3001Jupyter Notebook\u3001\u5728\u7ebf\u89e3\u91ca\u5668\uff0c\u8fd8\u662f\u4f7f\u7528\u865a\u62df\u73af\u5883\uff0c\u4f60\u90fd\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u9009\u62e9\u9002\u5408\u7684\u65b9\u5f0f\u6765\u8fdb\u884cPython\u5f00\u53d1\u3002\u5e0c\u671b\u8fd9\u4e9b\u65b9\u6cd5\u80fd\u591f\u5e2e\u52a9\u4f60\u5728Python\u7f16\u7a0b\u7684\u65c5\u7a0b\u4e2d\u66f4\u52a0\u987a\u5229\u548c\u9ad8\u6548\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u6253\u5f00Python\u63a7\u5236\u53f0\uff1f<\/strong><br \/>\u5728Windows\u4e0a\uff0c\u53ef\u4ee5\u901a\u8fc7\u5f00\u59cb\u83dc\u5355\u627e\u5230\u201c\u547d\u4ee4\u63d0\u793a\u7b26\u201d\u6216\u201cWindows PowerShell\u201d\uff0c\u7136\u540e\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\u6765\u542f\u52a8Python\u63a7\u5236\u53f0\u3002\u5728MacOS\u548cLinux\u4e2d\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165\u76f8\u540c\u7684\u547d\u4ee4\u5373\u53ef\u3002\u786e\u4fdd\u5728\u7cfb\u7edf\u4e2d\u5df2\u5b89\u88c5Python\uff0c\u5e76\u4e14\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u6b63\u786e\u3002<\/p>\n<p><strong>Python\u63a7\u5236\u53f0\u7684\u57fa\u672c\u529f\u80fd\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>Python\u63a7\u5236\u53f0\u5141\u8bb8\u7528\u6237\u76f4\u63a5\u8f93\u5165Python\u4ee3\u7801\u5e76\u7acb\u5373\u67e5\u770b\u7ed3\u679c\u3002\u8fd9\u662f\u6d4b\u8bd5\u5c0f\u6bb5\u4ee3\u7801\u3001\u8fdb\u884c\u5feb\u901f\u8ba1\u7b97\u6216\u8c03\u8bd5\u7a0b\u5e8f\u7684\u7406\u60f3\u73af\u5883\u3002\u7528\u6237\u53ef\u4ee5\u4f7f\u7528\u63a7\u5236\u53f0\u8fdb\u884c\u53d8\u91cf\u5b9a\u4e49\u3001\u51fd\u6570\u8c03\u7528\u4ee5\u53ca\u6a21\u5757\u5bfc\u5165\u7b49\u64cd\u4f5c\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u63a7\u5236\u53f0\u4e2d\u6267\u884c\u591a\u884c\u4ee3\u7801\uff1f<\/strong><br \/>\u5728Python\u63a7\u5236\u53f0\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u4e09\u5f15\u53f7\uff08<code>&#39;&#39;&#39;<\/code>\u6216<code>&quot;&quot;&quot;<\/code>\uff09\u6765\u5b9a\u4e49\u591a\u884c\u5b57\u7b26\u4e32\uff0c\u5e76\u5728\u5b57\u7b26\u4e32\u5185\u90e8\u7f16\u5199\u591a\u884c\u4ee3\u7801\u3002\u6b64\u5916\uff0c\u7528\u6237\u8fd8\u53ef\u4ee5\u4f7f\u7528\u7f29\u8fdb\u6765\u521b\u5efa\u51fd\u6570\u6216\u63a7\u5236\u7ed3\u6784\uff0c\u5982\u5faa\u73af\u548c\u6761\u4ef6\u8bed\u53e5\u3002\u8fd9\u6837\u53ef\u4ee5\u5728\u63a7\u5236\u53f0\u4e2d\u6709\u6548\u5730\u7ec4\u7ec7\u548c\u6d4b\u8bd5\u590d\u6742\u7684\u4ee3\u7801\u903b\u8f91\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u628aPython\u7684console\u8c03\u51fa\u6765\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\u3001\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165 python \u6216 python3 [&hellip;]","protected":false},"author":3,"featured_media":1084197,"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\/1084187"}],"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=1084187"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1084187\/revisions"}],"predecessor-version":[{"id":1084202,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1084187\/revisions\/1084202"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1084197"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1084187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1084187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1084187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}