{"id":173024,"date":"2024-05-08T18:03:02","date_gmt":"2024-05-08T10:03:02","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/173024.html"},"modified":"2024-05-08T18:03:12","modified_gmt":"2024-05-08T10:03:12","slug":"ipython%e4%b8%8epython%e7%9a%84%e8%af%ad%e6%b3%95%e6%9c%89%e4%bb%80%e4%b9%88%e5%8c%ba%e5%88%ab%e5%90%97","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/173024.html","title":{"rendered":"iPython\u4e0ePython\u7684\u8bed\u6cd5\u6709\u4ec0\u4e48\u533a\u522b\u5417"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27044821\/8a9032d8-d6a7-4f9c-8c57-3618470af77b.webp\" alt=\"iPython\u4e0ePython\u7684\u8bed\u6cd5\u6709\u4ec0\u4e48\u533a\u522b\u5417\" \/><\/p>\n<p><p>iPython \u4e0e Python \u7684\u57fa\u672c\u8bed\u6cd5\u6ca1\u6709\u5dee\u5f02\uff0c\u5b83\u4eec\u4e4b\u95f4\u7684\u4e3b\u8981\u533a\u522b\u5728\u4e8e\u4ea4\u4e92\u6027\u548c\u529f\u80fd\u5f3a\u5927\u7684\u7279\u6027\u3002<strong>iPython \u63d0\u4f9b\u4e86\u4e00\u4e2a\u589e\u5f3a\u7684\u4ea4\u4e92\u5f0f\u754c\u9762\u3001\u5185\u7f6e\u7684\u8bb8\u591a\u4fbf\u6377\u529f\u80fd\u3001\u5982\u9b54\u6cd5\u547d\u4ee4\u3001\u5185\u5d4c\u7684\u53ef\u89c6\u5316\u5de5\u5177<\/strong>\uff0c\u4e0e\u6807\u51c6 Python \u89e3\u91ca\u5668\u76f8\u6bd4\uff0c\u5b83\u5728\u6570\u636e\u5206\u6790\u3001\u79d1\u5b66\u8ba1\u7b97\u548c\u6559\u80b2\u9886\u57df\u8868\u73b0\u51fa\u66f4\u9ad8\u7684\u6548\u7387\u3002\u5728\u8be6\u7ec6\u63cf\u8ff0\u65b9\u9762\uff0ciPython\u7684 <strong>\u201c\u9b54\u6cd5\u547d\u4ee4\u201d<\/strong> \u662f\u5176\u975e\u5e38\u72ec\u7279\u548c\u529f\u80fd\u5f3a\u5927\u7684\u7279\u70b9\uff0c\u5b83\u4eec\u662f\u4ee5\u767e\u5206\u53f7 <code>%<\/code> \u6216\u53cc\u767e\u5206\u53f7 <code>%%<\/code> \u4f5c\u4e3a\u524d\u7f00\u7684\u7279\u6b8a\u547d\u4ee4\uff0c\u53ef\u4ee5\u7528\u6765\u5feb\u901f\u6267\u884c\u7279\u5b9a\u7684\u4efb\u52a1\uff0c\u4f8b\u5982 <code>%timeit<\/code> \u7528\u4e8e\u6d4b\u91cf\u4ee3\u7801\u7684\u6267\u884c\u65f6\u95f4\uff0c<code>%matplotlib inline<\/code> \u7528\u4e8e\u5728 iPython \u7b14\u8bb0\u672c\u4e2d\u5185\u5d4c\u663e\u793a matplotlib \u56fe\u8868\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4ea4\u4e92\u5f0f\u7f16\u7a0b\u4f53\u9a8c<\/h3>\n<\/p>\n<p><p>iPython \u5f3a\u5316\u4e86 Python \u7684\u4ea4\u4e92\u5f0f\u7f16\u7a0b\u4f53\u9a8c\uff0c\u4f7f\u5f97\u7528\u6237\u80fd\u591f\u4ee5\u66f4\u4e3a\u4fbf\u5229\u7684\u65b9\u5f0f\u8fdb\u884c\u4ee3\u7801\u7684\u7f16\u5199\u548c\u7ed3\u679c\u7684\u68c0\u9a8c\u3002\u5b83\u652f\u6301\u81ea\u52a8\u7f29\u8fdb\u3001\u989c\u8272\u9ad8\u4eae\u3001\u4ee5\u53ca<strong>\u4e30\u5bcc\u7684\u5386\u53f2\u547d\u4ee4\u8bb0\u5f55<\/strong>\uff0c\u8fd9\u4f7f\u5f97\u7f16\u5199\u548c\u6d4b\u8bd5\u4ee3\u7801\u53d8\u5f97\u76f8\u5bf9\u8f7b\u677e\u3002<\/p>\n<\/p>\n<p><h4>\u589e\u5f3a\u7684\u81ea\u52a8\u8865\u5168\u529f\u80fd<\/h4>\n<\/p>\n<p><p>\u4e00\u4e2a\u503c\u5f97\u63d0\u53ca\u7684\u70b9\u662f iPython \u7684\u81ea\u52a8\u8865\u5168\u529f\u80fd\uff0c\u5b83\u8d85\u8d8a\u4e86\u6807\u51c6 Python \u89e3\u91ca\u5668\u7684\u8865\u5168\u80fd\u529b\u3002\u5728 iPython \u7ec8\u7aef\u4e2d\uff0c\u5f53\u4f60\u5f00\u59cb\u8f93\u5165\u4e00\u4e2a\u5bf9\u8c61\u7684\u65b9\u6cd5\u6216\u5c5e\u6027\u5e76\u6309\u4e0b <code>Tab<\/code> \u952e\u65f6\uff0ciPython \u4f1a\u663e\u793a\u4e00\u4e2a\u4e0b\u62c9\u5217\u8868\u4f9b\u4f60\u9009\u62e9\uff0c\u8fd9\u6781\u5927\u5730\u63d0\u5347\u4e86\u7f16\u7801\u7684\u6548\u7387\u3002<\/p>\n<\/p>\n<p><h4>\u9ad8\u7ea7\u7684\u5386\u53f2\u547d\u4ee4\u7279\u6027<\/h4>\n<\/p>\n<p><p>\u53e6\u4e00\u4e2a\u63d0\u9ad8\u4ea4\u4e92\u6027\u7684\u4f8b\u5b50\u662f iPython \u7684\u5386\u53f2\u547d\u4ee4\u529f\u80fd\u3002\u4e0d\u4ec5\u80fd\u591f\u56de\u6eaf\u4e4b\u524d\u7684\u547d\u4ee4\uff0ciPython \u8fd8\u5141\u8bb8\u5bf9\u4ee5\u5f80\u547d\u4ee4\u8fdb\u884c\u641c\u7d22\uff0c\u4fdd\u5b58\u4ee5\u53ca\u91cd\u65b0\u6267\u884c\uff0c\u8fd9\u4e3a\u53cd\u590d\u6d4b\u8bd5\u548c\u8c03\u8bd5\u4ee3\u7801\u63d0\u4f9b\u4e86\u6781\u5927\u7684\u4fbf\u5229\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u9b54\u6cd5\u547d\u4ee4<\/h3>\n<\/p>\n<p><p>iPython \u7684\u9b54\u6cd5\u547d\u4ee4\u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u8bf8\u591a\u5feb\u6377\u64cd\u4f5c\uff0c\u5b83\u4eec\u662f iPython \u72ec\u6709\u7684\u547d\u4ee4\uff0c\u53ef\u4ee5\u901a\u8fc7\u5355\u884c\u6216\u8005\u6574\u4e2a\u5355\u5143\u683c\u6765\u6267\u884c\u7279\u6b8a\u7684\u4efb\u52a1\u3002<\/p>\n<\/p>\n<p><h4>\u5355\u884c\u548c\u591a\u884c\u9b54\u6cd5\u547d\u4ee4<\/h4>\n<\/p>\n<p><p><strong>\u5355\u884c\u9b54\u6cd5\u547d\u4ee4<\/strong>\uff0c\u5982 <code>%timeit<\/code>\uff0c\u901a\u5e38\u7528\u6765\u6d4b\u8bd5\u5355\u884c\u4ee3\u7801\u7684\u6267\u884c\u65f6\u95f4\u3002\u800c<strong>\u591a\u884c\u9b54\u6cd5\u547d\u4ee4<\/strong>\uff0c\u5982 <code>%%timeit<\/code>\uff0c\u5219\u53ef\u4ee5\u7528\u6765\u6d4b\u8bd5\u6574\u4e2a\u5355\u5143\u683c\u4e2d\u4ee3\u7801\u7684\u6267\u884c\u65f6\u95f4\u3002\u8fd9\u4e9b\u547d\u4ee4\u5bf9\u4e8e\u6027\u80fd\u8c03\u4f18\u6765\u8bf4\u6781\u5176\u6709\u7528\u3002<\/p>\n<\/p>\n<p><h4>\u7cfb\u7edf\u76f8\u5173\u7684\u9b54\u6cd5\u547d\u4ee4<\/h4>\n<\/p>\n<p><p>iPython \u8fd8\u5305\u542b\u4e00\u4e9b\u8ba9\u4f60\u76f4\u63a5\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u8fdb\u884c\u4ea4\u4e92\u7684\u9b54\u6cd5\u547d\u4ee4\u3002\u4f8b\u5982 <code>%cd<\/code>\u3001<code>%ls<\/code>\u3001<code>%env<\/code> \u7b49\uff0c\u8fd9\u610f\u5473\u7740\u4f60\u53ef\u4ee5\u5728\u4e0d\u79bb\u5f00 iPython \u73af\u5883\u7684\u60c5\u51b5\u4e0b\u6267\u884c shell \u547d\u4ee4\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u5d4c\u5165\u5f0f\u53ef\u89c6\u5316\u5de5\u5177<\/h3>\n<\/p>\n<p><p>iPython \u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u53ef\u89c6\u5316\u652f\u6301\uff0c\u5b83\u53ef\u4ee5\u4e0e\u591a\u79cd\u7ed8\u56fe\u5e93\u6574\u5408\uff0c\u5982 Matplotlib\u3001Bokeh \u548c Plotly\uff0c\u5e76\u5185\u5d4c\u663e\u793a\u7ed8\u5236\u7684\u56fe\u8868\u3002<\/p>\n<\/p>\n<p><h4>\u5185\u5d4c\u663e\u793a\u56fe\u8868<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528 iPython \u65f6\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728\u8f93\u51fa\u4e2d<strong>\u5185\u5d4c\u56fe\u5f62\u5316\u663e\u793a<\/strong>\uff0c\u800c\u4e0d\u9700\u8981\u5728\u5916\u90e8\u7a97\u53e3\u4e2d\u6253\u5f00\u3002\u8fd9\u4e00\u70b9\u901a\u8fc7 <code>%matplotlib inline<\/code> \u9b54\u6cd5\u547d\u4ee4\u8f7b\u677e\u5b9e\u73b0\uff0c\u5b83\u4e3a\u6570\u636e\u5206\u6790\u63d0\u4f9b\u4e86\u6781\u5927\u7684\u65b9\u4fbf\u3002<\/p>\n<\/p>\n<p><h4>\u4e0e\u591a\u79cd\u7ed8\u56fe\u5e93\u6574\u5408<\/h4>\n<\/p>\n<p><p>\u4e3a\u4e86\u5b9e\u73b0\u66f4\u4e3a\u590d\u6742\u7684\u53ef\u89c6\u5316\u9700\u6c42\uff0ciPython \u652f\u6301\u4e0e\u591a\u79cd\u7ed8\u56fe\u5e93\u7684\u6574\u5408\u4f7f\u7528\u3002\u8fd9\u610f\u5473\u7740\u4f60\u53ef\u4ee5\u5229\u7528\u8fd9\u4e9b\u56fe\u5f62\u5e93\u4ea7\u751f\u5177\u6709\u4e92\u52a8\u6027\u8d28\u7684\u56fe\u5f62\uff0c\u5e76\u76f4\u63a5\u5728 iPython \u4e2d\u8fdb\u884c\u64cd\u4f5c\u548c\u89c2\u5bdf\u6548\u679c\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4e0e\u5176\u4ed6\u5de5\u5177\u7684\u6574\u5408<\/h3>\n<\/p>\n<p><p>iPython \u7684\u4f18\u52bf\u4e0d\u6b62\u4e8e\u6b64\uff0c\u5b83\u8fd8\u80fd\u591f\u4e0e\u4f17\u591a\u5176\u4ed6\u5de5\u5177\u534f\u540c\u5de5\u4f5c\uff0c\u5982 Jupyter Notebook\u3001Pandas \u7b49\uff0c\u8fd9\u63d0\u9ad8\u4e86\u5b83\u5728\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u5206\u6790\u65b9\u9762\u7684\u5e94\u7528\u4ef7\u503c\u3002<\/p>\n<\/p>\n<p><h4>\u6574\u5408 Jupyter Notebook<\/h4>\n<\/p>\n<p><p><strong>Jupyter Notebook \u662f\u57fa\u4e8e iPython \u7684\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u7b14\u8bb0\u672c\u73af\u5883<\/strong>\uff0c\u5b83\u652f\u6301\u4ee3\u7801\u3001\u6587\u672c\u3001\u6570\u5b66\u516c\u5f0f\u548c\u56fe\u8868\u7684\u6df7\u5408\u5c55\u793a\uff0c\u8fd9\u8ba9\u6f14\u793a\u548c\u6559\u5b66\u53d8\u5f97\u975e\u5e38\u76f4\u89c2\u3002<\/p>\n<\/p>\n<p><h4>\u652f\u6301\u591a\u79cd\u6570\u636e\u5904\u7406\u5de5\u5177<\/h4>\n<\/p>\n<p><p>iPython \u5bf9\u4e8e\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u5de5\u5177\u7684\u652f\u6301\u4e5f\u5341\u5206\u5e7f\u6cdb\uff0c\u4f8b\u5982\u53ef\u4ee5\u65e0\u7f1d\u4f7f\u7528 Pandas\u3001NumPy \u7b49\u5f3a\u5927\u7684\u5e93\u6765\u5904\u7406\u6570\u636e\uff0c\u8fd9\u4f7f\u5f97\u5b83\u6210\u4e3a\u6570\u636e\u79d1\u5b66\u5bb6\u7684\u5f97\u529b\u52a9\u624b\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u5b9a\u5236\u5316\u548c\u6269\u5c55\u6027<\/h3>\n<\/p>\n<p><p>\u4f5c\u4e3a\u4e00\u4e2a\u7075\u6d3b\u7684\u4ea4\u4e92\u5f0f\u7f16\u7a0b\u73af\u5883\uff0ciPython \u5141\u8bb8\u7528\u6237\u5b9a\u5236\u5176\u754c\u9762\u548c\u884c\u4e3a\uff0c\u4e5f\u652f\u6301\u6dfb\u52a0\u6269\u5c55\u6765\u589e\u5f3a\u5176\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h4>\u7528\u6237\u754c\u9762\u5b9a\u5236<\/h4>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u5b9a\u5236 iPython \u7684\u63d0\u793a\u7b26\u3001\u5b57\u4f53\u989c\u8272\u3001\u80cc\u666f\u8272\u7b49\uff0c\u751a\u81f3\u6539\u53d8\u5176\u9ed8\u8ba4\u884c\u4e3a\uff0c\u4ee5\u9002\u5e94\u4e2a\u4eba\u7684\u504f\u597d\u3002<\/p>\n<\/p>\n<p><h4>\u6dfb\u52a0\u6269\u5c55<\/h4>\n<\/p>\n<p><p>iPython \u901a\u8fc7\u5176\u5f3a\u5927\u7684\u6269\u5c55\u6846\u67b6\u652f\u6301\u6dfb\u52a0\u65b0\u7684\u9b54\u6cd5\u547d\u4ee4\u3001\u65b0\u7684\u4ea4\u4e92\u5f0f\u63a7\u4ef6\u7b49\u3002\u8fd9\u4e3a\u9ad8\u7ea7\u7528\u6237\u63d0\u4f9b\u4e86\u5728\u5176\u57fa\u7840\u4e0a\u8fdb\u884c\u529f\u80fd\u589e\u5f3a\u7684\u53ef\u80fd\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. iPython\u4e0ePython\u7684\u8bed\u6cd5\u6709\u4f55\u4e0d\u540c\u4e4b\u5904\uff1f<\/strong><\/p>\n<p>iPython\u4e0ePython\u7684\u8bed\u6cd5\u5728\u5f88\u5927\u7a0b\u5ea6\u4e0a\u662f\u76f8\u540c\u7684\uff0c\u56e0\u4e3aiPython\u662fPython\u7684\u4e00\u79cd\u4ea4\u4e92\u5f0f\u73af\u5883\u3002\u7136\u800c\uff0ciPython\u63d0\u4f9b\u4e00\u4e9b\u989d\u5916\u7684\u529f\u80fd\u548c\u8bed\u6cd5\u7cd6\uff0c\u4f7f\u5f97\u5b83\u5728\u7f16\u5199\u548c\u6d4b\u8bd5\u4ee3\u7801\u65f6\u66f4\u52a0\u65b9\u4fbf\u3002<\/p>\n<p><strong>2. iPython\u662f\u5426\u652f\u6301Python\u7684\u6240\u6709\u8bed\u6cd5\u548c\u529f\u80fd\uff1f<\/strong><\/p>\n<p>\u662f\u7684\uff0ciPython\u5b8c\u5168\u652f\u6301Python\u7684\u6240\u6709\u8bed\u6cd5\u548c\u529f\u80fd\u3002\u4ece\u8bed\u6cd5\u89d2\u5ea6\u6765\u770b\uff0ciPython\u4e0ePython\u662f\u517c\u5bb9\u7684\uff0c\u53ef\u4ee5\u8fd0\u884cPython\u4ee3\u7801\u5e76\u5f97\u5230\u76f8\u540c\u7684\u7ed3\u679c\u3002iPython\u8fd8\u63d0\u4f9b\u4e86\u66f4\u9ad8\u7ea7\u7684\u4ea4\u4e92\u529f\u80fd\uff0c\u5982\u81ea\u52a8\u5b8c\u6210\u3001\u64cd\u4f5c\u5386\u53f2\u8bb0\u5f55\u3001\u5185\u7f6e\u547d\u4ee4\u7b49\uff0c\u4ee5\u63d0\u5347\u7f16\u7801\u6548\u7387\u3002<\/p>\n<p><strong>3. iPython\u7684\u8bed\u6cd5\u7cd6\u6709\u54ea\u4e9b\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7f16\u5199\u7684\u4fbf\u6377\u6027\uff1f<\/strong><\/p>\n<p>iPython\u63d0\u4f9b\u4e86\u4e00\u4e9b\u8bed\u6cd5\u7cd6\uff0c\u4f7f\u5f97\u5728\u4ea4\u4e92\u5f0f\u73af\u5883\u4e2d\u7f16\u5199\u4ee3\u7801\u66f4\u52a0\u7b80\u6d01\u548c\u65b9\u4fbf\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u201c\uff1f\u201d\u53ef\u4ee5\u83b7\u53d6\u5bf9\u8c61\u7684\u5e2e\u52a9\u6587\u6863\uff1b\u4f7f\u7528\u201c%run\u201d\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c\u811a\u672c\u6587\u4ef6\uff1b\u4f7f\u7528\u201c%matplotlib inline\u201d\u53ef\u4ee5\u5728iPython\u4e2d\u663e\u793aMatplotlib\u56fe\u5f62\u7b49\u3002\u8fd9\u4e9b\u8bed\u6cd5\u7cd6\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u5f00\u53d1\u8005\u7684\u5de5\u4f5c\u6548\u7387\uff0c\u5e76\u4f7f\u7f16\u7801\u8fc7\u7a0b\u66f4\u52a0\u6109\u5feb\u548c\u9ad8\u6548\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"iPython \u4e0e Python \u7684\u57fa\u672c\u8bed\u6cd5\u6ca1\u6709\u5dee\u5f02\uff0c\u5b83\u4eec\u4e4b\u95f4\u7684\u4e3b\u8981\u533a\u522b\u5728\u4e8e\u4ea4\u4e92\u6027\u548c\u529f\u80fd\u5f3a\u5927\u7684\u7279\u6027\u3002iPyth [&hellip;]","protected":false},"author":3,"featured_media":173039,"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\/173024"}],"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=173024"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/173024\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/173039"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=173024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=173024"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=173024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}