{"id":300914,"date":"2024-05-20T17:54:28","date_gmt":"2024-05-20T09:54:28","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/300914.html"},"modified":"2024-05-20T17:54:40","modified_gmt":"2024-05-20T09:54:40","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8jupyter%e4%b8%ad%e8%bf%90%e8%a1%8c%e5%a4%9a%e4%b8%aacell%e4%b8%ad%e5%86%85%e5%ae%b9","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/300914.html","title":{"rendered":"\u5982\u4f55\u5728jupyter\u4e2d\u8fd0\u884c\u591a\u4e2acell\u4e2d\u5185\u5bb9"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/26213049\/7f5a5313-9207-478f-b5b7-e0640d7ac4fa.webp\" alt=\"\u5982\u4f55\u5728jupyter\u4e2d\u8fd0\u884c\u591a\u4e2acell\u4e2d\u5185\u5bb9\" \/><\/p>\n<p><p>\u8981\u5728Jupyter\u4e2d\u8fd0\u884c\u591a\u4e2acell\u4e2d\u7684\u5185\u5bb9\uff0c\u4e3b\u8981\u624b\u6bb5\u6709<strong>\u4f7f\u7528\u5feb\u6377\u952e\u3001\u6279\u91cf\u8fd0\u884c\u4ee5\u53ca\u5229\u7528\u9b54\u672f\u547d\u4ee4<\/strong>\u3002\u8fd9\u4e9b\u64cd\u4f5c\u4e0d\u4ec5\u63d0\u9ad8\u4e86\u5de5\u4f5c\u6548\u7387\uff0c\u8fd8\u8ba9\u6570\u636e\u5206\u6790\u548c\u53ef\u89c6\u5316\u7684\u8fc7\u7a0b\u53d8\u5f97\u66f4\u52a0\u6d41\u7545\u3002<strong>\u6279\u91cf\u8fd0\u884c<\/strong>\u5c24\u5176\u9002\u7528\u4e8e\u9700\u8981\u8fde\u7eed\u6267\u884c\u591a\u4e2a\u5355\u5143\u683c\u4ee5\u8fdb\u884c\u6570\u636e\u9884\u5904\u7406\u3001\u53ef\u89c6\u5316\u6216\u4efb\u4f55\u5f62\u5f0f\u7684\u5206\u6790\u7684\u60c5\u51b5\u3002\u6279\u91cf\u8fd0\u884c\u53ef\u4ee5\u901a\u8fc7\u9009\u62e9\u9700\u8981\u6267\u884c\u7684\u5355\u5143\u683c\uff0c\u7136\u540e\u4f7f\u7528\u76f8\u5e94\u7684\u9009\u9879\u6216\u5feb\u6377\u952e\u6765\u5b8c\u6210\u3002\u8fd9\u6837\uff0c\u7528\u6237\u53ef\u4ee5\u4e00\u6b21\u6027\u6267\u884c\u591a\u4e2a\u6b65\u9aa4\uff0c\u800c\u65e0\u9700\u9010\u4e00\u70b9\u51fb\u6bcf\u4e2a\u5355\u5143\u683c\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528\u5feb\u6377\u952e<\/h3>\n<\/p>\n<p><p>Jupyter Notebook\u652f\u6301\u591a\u79cd\u5feb\u6377\u952e\uff0c\u53ef\u4ee5\u9ad8\u6548\u5730\u8fd0\u884c\u591a\u4e2acell\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>Shift + Enter<\/strong>\uff1a\u8fd9\u662f\u6700\u5e38\u89c1\u7684\u6267\u884c\u5355\u4e2acell\u7684\u65b9\u6cd5\uff0c\u5b83\u6267\u884c\u5f53\u524dcell\u5e76\u5c06\u5149\u6807\u79fb\u52a8\u5230\u4e0b\u4e00\u4e2acell\u3002\u8fde\u7eed\u6309\u4e0b\u53ef\u4ee5\u5b9e\u73b0\u591a\u4e2acell\u7684\u4f9d\u6b21\u8fd0\u884c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>Alt + Enter<\/strong>\uff1a\u8fd9\u4e2a\u5feb\u6377\u952e\u6267\u884c\u5f53\u524dcell\uff0c\u5e76\u5728\u4e0b\u65b9\u63d2\u5165\u4e00\u4e2a\u65b0\u7684\u7a7acell\uff0c\u975e\u5e38\u9002\u5408\u8fde\u7eed\u6d4b\u8bd5\u5e76\u589e\u52a0\u65b0\u5185\u5bb9\u7684\u573a\u666f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u8fde\u7eed\u4f7f\u7528\u8fd9\u4e9b\u5feb\u6377\u952e\uff0c\u5c24\u5176\u662fShift + Enter\uff0c\u53ef\u4ee5\u5b9e\u73b0\u5bf9\u591a\u4e2acell\u7684\u5feb\u901f\u8fde\u7eed\u8fd0\u884c\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u6279\u91cf\u8fd0\u884c<\/h3>\n<\/p>\n<p><p>\u5728Jupyter Notebook\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u83dc\u5355\u680f\u7684\u9009\u9879\u6765\u6267\u884c\u591a\u4e2acell\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4ece\u5f53\u524dcell\u8fd0\u884c\u5230\u6587\u6863\u7ed3\u675f<\/strong>\uff1a\u9009\u62e9\u201cCell\u201d\u83dc\u5355\u4e0b\u7684\u201cRun All Below\u201d\uff0c\u53ef\u4ee5\u4ece\u5f53\u524d\u9009\u4e2d\u7684cell\u8fd0\u884c\u76f4\u5230\u6587\u6863\u7684\u6700\u540e\u4e00\u4e2acell\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884c\u5168\u90e8cell<\/strong>\uff1a\u901a\u8fc7\u201cCell\u201d\u83dc\u5355\u4e0b\u7684\u201cRun All\u201d\uff0c\u53ef\u4ee5\u6267\u884cNotebook\u4e2d\u7684\u6240\u6709cell\uff0c\u8fd9\u5bf9\u4e8e\u91cd\u65b0\u521d\u59cb\u5316\u5b9e\u9a8c\u73af\u5883\u6216\u5168\u9762\u68c0\u67e5Notebook\u7684\u8fd0\u884c\u975e\u5e38\u6709\u7528\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u7b80\u4fbf\u6613\u884c\uff0c\u65e0\u9700\u8bb0\u5fc6\u5feb\u6377\u952e\uff0c\u7279\u522b\u9002\u5408\u65b0\u624b\u7528\u6237\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u5229\u7528\u9b54\u672f\u547d\u4ee4<\/h3>\n<\/p>\n<p><p>Jupyter Notebook\u7684\u9b54\u672f\u547d\u4ee4\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u9ad8\u7ea7\u64cd\u4f5c\uff0c\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e\u6267\u884c\u591a\u4e2acell\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>%run \u9b54\u672f\u547d\u4ee4<\/strong>\uff1a\u53ef\u4ee5\u52a0\u8f7d\u5e76\u6267\u884c\u5176\u4ed6Notebook\u6587\u4ef6\u6216Python\u811a\u672c\u3002\u8fd9\u6837\uff0c\u7528\u6237\u53ef\u4ee5\u5c06\u957f\u4ee3\u7801\u5206\u5272\u5230\u4e0d\u540c\u7684Notebook\u4e2d\uff0c\u901a\u8fc7%run\u547d\u4ee4\u8c03\u7528\u6267\u884c\uff0c\u786e\u4fdd\u4ee3\u7801\u7684\u6a21\u5757\u5316\u548c\u53ef\u91cd\u7528\u6027\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>%store \u547d\u4ee4<\/strong>\uff1a\u8fd9\u662f\u5b9e\u73b0\u6570\u636e\u5728\u4e0d\u540cNotebook\u95f4\u5171\u4eab\u7684\u5f3a\u5927\u5de5\u5177\u3002\u901a\u8fc7%store\u547d\u4ee4\uff0c\u7528\u6237\u53ef\u4ee5\u5728\u4e00\u4e2aNotebook\u4e2d\u8fd0\u884c\u67d0\u4e9b\u8ba1\u7b97\uff0c\u5e76\u5c06\u7ed3\u679c\u5b58\u50a8\u8d77\u6765\uff0c\u7136\u540e\u5728\u53e6\u4e00\u4e2aNotebook\u4e2d\u8bbf\u95ee\u8fd9\u4e9b\u6570\u636e\uff0c\u4ece\u800c\u5b9e\u73b0\u8de8Notebook\u7684\u6570\u636e\u6d41\u901a\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u8fd9\u4e9b\u9ad8\u7ea7\u64cd\u4f5c\u5927\u5927\u6269\u5c55\u4e86Jupyter Notebook\u7684\u4f7f\u7528\u573a\u666f\uff0c\u4f7f\u5176\u4e0d\u4ec5\u9650\u4e8e\u5355\u4e2aNotebook\u5185\u7684\u4ea4\u4e92\u5f0f\u8ba1\u7b97\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u8fd0\u884cJupyter\u4e2d\u591a\u4e2acell\u7684\u5185\u5bb9\u65e2\u53ef\u4ee5\u901a\u8fc7\u5feb\u6377\u952e\u5b9e\u73b0\u5feb\u901f\u64cd\u4f5c\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u83dc\u5355\u680f\u8fdb\u884c\u6279\u91cf\u8fd0\u884c\uff0c\u6216\u8005\u501f\u52a9\u9b54\u672f\u547d\u4ee4\u6765\u6267\u884c\u66f4\u4e3a\u590d\u6742\u7684\u4efb\u52a1\u3002\u6bcf\u79cd\u65b9\u5f0f\u90fd\u6709\u5176\u9002\u7528\u573a\u666f\uff0c\u7075\u6d3b\u8fd0\u7528\u53ef\u4ee5\u5927\u5e45\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\u3002\u5c24\u5176\u662f\u5229\u7528\u6279\u91cf\u8fd0\u884c\uff0c\u5bf9\u4e8e\u6570\u636e\u6e05\u6d17\u3001\u5206\u6790\u53ca\u53ef\u89c6\u5316\u7b49\u8fde\u7eed\u6b65\u9aa4\u7684\u6267\u884c\uff0c\u53ef\u4ee5\u8282\u7ea6\u5927\u91cf\u65f6\u95f4\uff0c\u8ba9\u7528\u6237\u805a\u7126\u4e8e\u6570\u636e\u5206\u6790\u7684\u903b\u8f91\u548c\u7ed3\u679c\uff0c\u63d0\u9ad8\u6574\u4f53\u7684\u5de5\u4f5c\u6548\u7387\u548c\u8d28\u91cf\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u5982\u4f55\u5728jupyter\u4e2d\u987a\u5e8f\u8fd0\u884c\u591a\u4e2acell\u4e2d\u7684\u5185\u5bb9\uff1f<\/strong><\/p>\n<p>\u5728Jupyter\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5feb\u6377\u952eShift+Enter\u6216\u8005Ctrl+Enter\u9010\u4e2a\u8fd0\u884c\u5355\u72ec\u7684\u4ee3\u7801\u5355\u5143\uff08cell\uff09\u3002\u4f46\u662f\u5982\u679c\u60a8\u60f3\u8981\u987a\u5e8f\u8fd0\u884c\u591a\u4e2a\u4ee3\u7801\u5355\u5143\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>\u65b9\u6cd5\u4e00\uff1a\u4f7f\u7528\u83dc\u5355\u680f\u7684&quot;Run&quot;\u9009\u9879\u3002\u4f9d\u6b21\u9009\u4e2d\u60a8\u8981\u8fd0\u884c\u7684\u4ee3\u7801\u5355\u5143\uff0c\u7136\u540e\u901a\u8fc7\u70b9\u51fb\u83dc\u5355\u680f\u4e2d\u7684&quot;Run&quot;\u9009\u9879\u6765\u987a\u5e8f\u8fd0\u884c\u8fd9\u4e9b\u4ee3\u7801\u5355\u5143\u3002<\/li>\n<li>\u65b9\u6cd5\u4e8c\uff1a\u4f7f\u7528\u5feb\u6377\u952eAlt+Enter\u3002\u5728Jupyter\u4e2d\uff0c\u5f53\u60a8\u6309\u4e0b\u5feb\u6377\u952eAlt+Enter\u65f6\uff0c\u5b83\u4f1a\u8fd0\u884c\u5f53\u524d\u4ee3\u7801\u5355\u5143\u5e76\u5728\u4e0b\u65b9\u63d2\u5165\u4e00\u4e2a\u65b0\u7684\u4ee3\u7801\u5355\u5143\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u4e0d\u65ad\u6309\u4e0b\u6b64\u5feb\u6377\u952e\u6765\u987a\u5e8f\u8fd0\u884c\u591a\u4e2a\u4ee3\u7801\u5355\u5143\u3002<\/li>\n<\/ul>\n<p><strong>2. \u5982\u4f55\u5728jupyter\u4e2d\u540c\u65f6\u8fd0\u884c\u591a\u4e2acell\u4e2d\u7684\u5185\u5bb9\uff1f<\/strong><\/p>\n<p>\u5728Jupyter\u4e2d\uff0c\u60a8\u53ef\u4ee5\u542f\u52a8\u591a\u4e2akernel\uff08\u5185\u6838\uff09\u6765\u540c\u65f6\u8fd0\u884c\u591a\u4e2a\u4ee3\u7801\u5355\u5143\u3002\u6bcf\u4e2a\u4ee3\u7801\u5355\u5143\u90fd\u5728\u81ea\u5df1\u7684kernel\u4e2d\u72ec\u7acb\u8fd0\u884c\uff0c\u5e76\u4e14\u5b83\u4eec\u4e4b\u95f4\u6ca1\u6709\u5f71\u54cd\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u6b64\u76ee\u7684\u7684\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>\u65b9\u6cd5\u4e00\uff1a\u5728Jupyter\u4e3b\u754c\u9762\u4e0a\u9009\u62e9&quot;New&quot;\uff0c\u7136\u540e\u9009\u62e9&quot;Notebook&quot;\u3002\u8fd9\u5c06\u6253\u5f00\u4e00\u4e2a\u65b0\u7684notebook\u7a97\u53e3\uff0c\u60a8\u53ef\u4ee5\u5728\u5176\u4e2d\u540c\u65f6\u8fd0\u884c\u591a\u4e2a\u4ee3\u7801\u5355\u5143\u3002<\/li>\n<li>\u65b9\u6cd5\u4e8c\uff1a\u5728Jupyter\u4e3b\u754c\u9762\u4e0a\u9009\u62e9&quot;New&quot;\uff0c\u7136\u540e\u9009\u62e9&quot;Terminal&quot;\u3002\u8fd9\u5c06\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\u7a97\u53e3\uff0c\u5728\u5176\u4e2d\u4f7f\u7528\u547d\u4ee4\u884c\u8fd0\u884c\u591a\u4e2aPython\u811a\u672c\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<p><strong>3. \u5982\u4f55\u5728jupyter\u4e2d\u63a7\u5236\u591a\u4e2acell\u4e2d\u7684\u8fd0\u884c\u987a\u5e8f\uff1f<\/strong><\/p>\n<p>\u5728Jupyter\u4e2d\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u79fb\u52a8\u4ee3\u7801\u5355\u5143\u7684\u4f4d\u7f6e\u6765\u63a7\u5236\u5b83\u4eec\u7684\u8fd0\u884c\u987a\u5e8f\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>\u65b9\u6cd5\u4e00\uff1a\u4f7f\u7528Jupyter\u7684\u62d6\u52a8\u529f\u80fd\u3002\u9f20\u6807\u60ac\u505c\u5728\u4ee3\u7801\u5355\u5143\u5de6\u8fb9\u7684\u8fb9\u754c\u4e0a\uff0c\u4f1a\u51fa\u73b0\u4e00\u4e2a\u5c0f\u62d6\u52a8\u56fe\u6807\uff0c\u60a8\u53ef\u4ee5\u70b9\u51fb\u5e76\u62d6\u52a8\u4ee3\u7801\u5355\u5143\u6765\u6539\u53d8\u5b83\u4eec\u7684\u4f4d\u7f6e\u3002<\/li>\n<li>\u65b9\u6cd5\u4e8c\uff1a\u4f7f\u7528\u83dc\u5355\u680f\u4e2d\u7684&quot;Edit&quot;\u9009\u9879\u3002\u9009\u4e2d\u60a8\u8981\u79fb\u52a8\u7684\u4ee3\u7801\u5355\u5143\uff0c\u7136\u540e\u901a\u8fc7\u70b9\u51fb\u83dc\u5355\u680f\u4e2d\u7684&quot;Edit&quot;\u9009\u9879\uff0c\u9009\u62e9&quot;Move Cell Up&quot;\u6216&quot;Move Cell Down&quot;\u6765\u6539\u53d8\u5b83\u4eec\u7684\u4f4d\u7f6e\u3002<\/li>\n<li>\u65b9\u6cd5\u4e09\uff1a\u4f7f\u7528\u5feb\u6377\u952eCtrl+\u4e0a\u7bad\u5934\u6216Ctrl+\u4e0b\u7bad\u5934\u3002\u9009\u4e2d\u60a8\u8981\u79fb\u52a8\u7684\u4ee3\u7801\u5355\u5143\uff0c\u7136\u540e\u6309\u4e0b\u7ec4\u5408\u952eCtrl+\u4e0a\u7bad\u5934\u6216Ctrl+\u4e0b\u7bad\u5934\u6765\u6539\u53d8\u5b83\u4eec\u7684\u4f4d\u7f6e\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"\u8981\u5728Jupyter\u4e2d\u8fd0\u884c\u591a\u4e2acell\u4e2d\u7684\u5185\u5bb9\uff0c\u4e3b\u8981\u624b\u6bb5\u6709\u4f7f\u7528\u5feb\u6377\u952e\u3001\u6279\u91cf\u8fd0\u884c\u4ee5\u53ca\u5229\u7528\u9b54\u672f\u547d\u4ee4\u3002\u8fd9\u4e9b\u64cd\u4f5c\u4e0d\u4ec5\u63d0\u9ad8 [&hellip;]","protected":false},"author":3,"featured_media":300930,"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\/300914"}],"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=300914"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/300914\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/300930"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=300914"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=300914"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=300914"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}