{"id":1533,"date":"2018-04-06T13:46:29","date_gmt":"2018-04-06T05:46:29","guid":{"rendered":"https:\/\/yanjingang.com\/blog\/?p=1533"},"modified":"2018-12-17T20:19:10","modified_gmt":"2018-12-17T12:19:10","slug":"jupyter-notebook-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8","status":"publish","type":"post","link":"https:\/\/yanjingang.com\/blog\/?p=1533","title":{"rendered":"Jupyter Notebook \u5feb\u901f\u5165\u95e8"},"content":{"rendered":"<div id=\"cnblogs_post_body\" class=\"blogpost-body\">\n<p>Jupyter Notebook\uff08\u6b64\u524d\u88ab\u79f0\u4e3a IPython notebook\uff09\u662f\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u7b14\u8bb0\u672c\uff0c\u652f\u6301\u8fd0\u884c 40 \u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd Jupyter notebook \u7684\u4e3b\u8981\u7279\u6027\uff0c\u4ee5\u53ca\u4e3a\u4ec0\u4e48\u5bf9\u4e8e\u5e0c\u671b\u7f16\u5199\u6f02\u4eae\u7684\u4ea4\u4e92\u5f0f\u6587\u6863\u7684\u4eba\u6765\u8bf4\u662f\u4e00\u4e2a\u5f3a\u5927\u5de5\u5177\u3002<\/p>\n<p>\u5728\u5f00\u59cb\u4f7f\u7528 notebook \u4e4b\u524d\uff0c\u6211\u4eec\u5148\u9700\u8981\u5b89\u88c5\u8be5\u5e93\u3002\u4f60\u53ef\u4ee5\u5728<a href=\"https:\/\/jupyter.readthedocs.org\/en\/latest\/install.html\">\u00a0Jupyter \u5b98\u7f51<\/a>\u4e0a\u627e\u5230\u5b8c\u6574\u7684\u6b65\u9aa4\u3002<\/p>\n<blockquote><p>aliyun\u5b89\u88c5\u6b65\u9aa4<\/p><\/blockquote>\n<pre class=\"pure-highlightjs\"><code class=\"\">#0.install\nsudo pip install jupyter nbconvert matplotlib\nsudo yum install pandoc texlive tkinter tcl-devel tk-devel -y\n\n#1.get passwd sign\nipython\n\tfrom notebook.auth import passwd; passwd()\n\tinput password &amp;&amp; get sha1 password Out[1]: 'sha1:f29ffxxxxxx:c5a57c13ee9a56618f83b3c53621xxxxxxxxxxxx'\n\n#2.conf\njupyter notebook --generate-config\nmkdir -p \/home\/work\/jupyter\/\nvim \/home\/work\/.jupyter\/jupyter_notebook_config.py\n\tc.NotebookApp.ip = '*'\n\tc.NotebookApp.open_browser = False\n\tc.NotebookApp.port = 8888\n\tc.NotebookApp.password = u'sha1:f29ffxxxxxxx:c5a57c13ee9a56618f83b3c53621xxxxxxxxxxxx'\n\tc.NotebookApp.notebook_dir = u'\/home\/work\/jupyter\/notebook\/'\n\n#3.start\nnohup jupyter notebook &gt; \/home\/work\/jupyter\/log\/jupyter.log &amp;\n\n#4.\u914d\u7f6ealiyun\u5b89\u5168\u7ec4\u89c4\u5219\n\u8bbe\u7f6e\u5165\u65b9\u5411\u5141\u8bb88888\u7aef\u53e3\u5f00\u653e\uff0c\u5426\u5219\u5916\u7f51\u65e0\u6cd5\u8bbf\u95ee\n#5.login\nhttp:\/\/47.92.25.83:8888\/<\/code><\/pre>\n<p>\u767b\u5f55Jupyter\u540e\u7684 \u4e3b\u754c\u9762\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p><a href=\"https:\/\/yanjingang.com\/blog\/?attachment_id=1534\" rel=\"attachment wp-att-1534\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1534\" src=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/1.jpg\" alt=\"\" width=\"661\" height=\"196\" srcset=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/1.jpg 661w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/1-300x89.jpg 300w\" sizes=\"(max-width: 661px) 100vw, 661px\" \/><\/a><\/p>\n<p>\u5982\u679c\u60f3\u65b0\u5efa\u4e00\u4e2a notebook\uff0c\u53ea\u9700\u8981\u70b9\u51fb<code>New<\/code>\uff0c\u9009\u62e9\u4f60\u5e0c\u671b\u542f\u52a8\u7684 notebook \u7c7b\u578b\u5373\u53ef\u3002<\/p>\n<p><a href=\"https:\/\/yanjingang.com\/blog\/?attachment_id=1535\" rel=\"attachment wp-att-1535\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1535\" src=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/2.jpg\" alt=\"\" width=\"661\" height=\"353\" srcset=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/2.jpg 661w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/2-300x160.jpg 300w\" sizes=\"(max-width: 661px) 100vw, 661px\" \/><\/a><\/p>\n<p>\u8fd9\u91cc\uff0c\u56e0\u4e3a\u6211\u53ea\u6709\u4e00\u4e2a Python \u5185\u6838\uff0c\u6240\u4ee5\u6211\u4eec\u8fd0\u884c\u4e00\u4e2a Python notebook\u3002\u5728\u65b0\u6253\u5f00\u7684\u6807\u7b7e\u9875\u4e2d\uff0c\u6211\u4eec\u4f1a\u770b\u5230 notebook \u754c\u9762\uff0c\u76ee\u524d\u91cc\u9762\u4ec0\u4e48\u4e5f\u6ca1\u6709\u3002<\/p>\n<p><a href=\"https:\/\/yanjingang.com\/blog\/?attachment_id=1536\" rel=\"attachment wp-att-1536\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1536\" src=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/3.jpg\" alt=\"\" width=\"661\" height=\"162\" srcset=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/3.jpg 661w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/3-300x74.jpg 300w\" sizes=\"(max-width: 661px) 100vw, 661px\" \/><\/a><\/p>\n<p>notebook \u754c\u9762\u7531\u4ee5\u4e0b\u90e8\u5206\u7ec4\u6210\uff1a<\/p>\n<ol>\n<li>notebook \u7684\u540d\u79f0<\/li>\n<li>\u4e3b\u5de5\u5177\u680f\uff0c\u63d0\u4f9b\u4e86\u4fdd\u5b58\u3001\u5bfc\u51fa\u3001\u91cd\u8f7d notebook\uff0c\u4ee5\u53ca\u91cd\u542f\u5185\u6838\u7b49\u9009\u9879<\/li>\n<li>\u5feb\u6377\u952e<\/li>\n<li>notebook \u4e3b\u8981\u533a\u57df\uff0c\u5305\u542b\u4e86 notebook \u7684\u5185\u5bb9\u7f16\u8f91\u533a<\/li>\n<\/ol>\n<p>\u6162\u6162\u719f\u6089\u8fd9\u4e9b\u83dc\u5355\u548c\u9009\u9879\u3002\u5982\u679c\u60f3\u8981\u8be6\u7ec6\u4e86\u89e3\u6709\u5173 notebook \u6216\u4e00\u4e9b\u5e93\u7684\u5177\u4f53\u8bdd\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528\u83dc\u5355\u680f\u53f3\u4fa7\u7684\u5e2e\u52a9\u83dc\u5355\u3002<\/p>\n<p>\u4e0b\u65b9\u7684\u4e3b\u8981\u533a\u57df\uff0c\u7531\u88ab\u79f0\u4e3a\u5355\u5143\u683c\u7684\u90e8\u5206\u7ec4\u6210\u3002\u6bcf\u4e2a notebook \u7531\u591a\u4e2a\u5355\u5143\u683c\u6784\u6210\uff0c\u800c\u6bcf\u4e2a\u5355\u5143\u683c\u53c8\u53ef\u4ee5\u6709\u4e0d\u540c\u7684\u7528\u9014\u3002<\/p>\n<p>\u4e0b\u65b9\u622a\u56fe\u4e2d\u770b\u5230\u7684\u662f\u4e00\u4e2a\u4ee3\u7801\u5355\u5143\u683c\uff08code cell\uff09\uff0c\u4ee5<code>[ ]<\/code>\u5f00\u5934\u3002\u5728\u8fd9\u79cd\u7c7b\u578b\u7684\u5355\u5143\u683c\u4e2d\uff0c\u53ef\u4ee5\u8f93\u5165\u4efb\u610f\u4ee3\u7801\u5e76\u6267\u884c\u3002\u4f8b\u5982\uff0c\u8f93\u5165<code>1 + 2<\/code>\u5e76\u6309\u4e0b<code>Shift + Enter<\/code>\u3002\u4e4b\u540e\uff0c\u5355\u5143\u683c\u4e2d\u7684\u4ee3\u7801\u5c31\u4f1a\u88ab\u8ba1\u7b97\uff0c\u5149\u6807\u4e5f\u4f1a\u88ab\u79fb\u52a8\u52a8\u4e00\u4e2a\u65b0\u7684\u5355\u5143\u683c\u4e2d\u3002\u4f60\u4f1a\u5f97\u5230\u5982\u4e0b\u7ed3\u679c\uff1a<\/p>\n<p><a href=\"https:\/\/yanjingang.com\/blog\/?attachment_id=1537\" rel=\"attachment wp-att-1537\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1537\" src=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/4.jpg\" alt=\"\" width=\"661\" height=\"214\" srcset=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/4.jpg 661w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/4-300x97.jpg 300w\" sizes=\"(max-width: 661px) 100vw, 661px\" \/><\/a><\/p>\n<p>\u6839\u636e\u7eff\u8272\u8fb9\u6846\u7ebf\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u8bc6\u522b\u51fa\u5f53\u524d\u5de5\u4f5c\u7684\u5355\u5143\u683c\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5728\u7b2c\u4e8c\u4e2a\u5355\u5143\u683c\u4e2d\u8f93\u5165\u4e9b\u5176\u4ed6\u4ee3\u7801\uff0c\u4f8b\u5982\uff1a<\/p>\n<div class=\"codehilite\">\n<pre><span class=\"k\">for <span class=\"n\">i <span class=\"ow\">in <span class=\"nb\">range<span class=\"p\">(<span class=\"mi\">5):\n    print(i)\n<\/span><\/span><\/span><\/span><\/span><\/span><\/pre>\n<\/div>\n<p>\u5bf9\u4e0a\u9762\u7684\u4ee3\u7801\u6c42\u503c\u65f6\uff0c\u4f60\u4f1a\u5f97\u5230\uff1a<\/p>\n<p><a href=\"https:\/\/yanjingang.com\/blog\/?attachment_id=1538\" rel=\"attachment wp-att-1538\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1538\" src=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/5.jpg\" alt=\"\" width=\"661\" height=\"344\" srcset=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/5.jpg 661w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/5-300x156.jpg 300w\" sizes=\"(max-width: 661px) 100vw, 661px\" \/><\/a><\/p>\n<p>\u548c\u524d\u4e00\u4e2a\u793a\u4f8b\u4e00\u6837\uff0c\u4ee3\u7801\u88ab\u8ba1\u7b97\u4e4b\u540e\uff0c\u9a6c\u4e0a\u5c31\u4f1a\u663e\u793a\u7ed3\u679c\u3002\u4f60\u5e94\u8be5\u6ce8\u610f\u5230\u4e86\uff0c\u8fd9\u6b21\u6ca1\u6709\u51fa\u73b0\u7c7b\u4f3c<code>Out[2]<\/code>\u8fd9\u6837\u7684\u6587\u5b57\u3002\u8fd9\u662f\u56e0\u4e3a\u6211\u4eec\u5c06\u7ed3\u679c\u6253\u5370\u51fa\u6765\u4e86\uff0c\u6ca1\u6709\u8fd4\u56de\u4efb\u4f55\u7684\u503c\u3002<\/p>\n<p>notebook \u6709\u4e00\u4e2a\u975e\u5e38\u6709\u8da3\u7684\u7279\u6027\uff0c\u5c31\u662f\u53ef\u4ee5\u4fee\u6539\u4e4b\u524d\u7684\u5355\u5143\u683c\uff0c\u5bf9\u5176\u91cd\u65b0\u8ba1\u7b97\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u66f4\u65b0\u6574\u4e2a\u6587\u6863\u4e86\u3002\u8bd5\u7740\u628a\u5149\u6807\u79fb\u56de\u7b2c\u4e00\u4e2a\u5355\u5143\u683c\uff0c\u5e76\u5c06<code>1 + 2<\/code>\u4fee\u6539\u6210<code>2 + 3<\/code>\uff0c\u7136\u540e\u6309\u4e0b<code>Shift + Enter<\/code>\u91cd\u65b0\u8ba1\u7b97\u8be5\u5355\u5143\u683c\u3002\u4f60\u4f1a\u53d1\u73b0\u7ed3\u679c\u9a6c\u4e0a\u5c31\u66f4\u65b0\u6210\u4e86 5\u3002\u5982\u679c\u4f60\u4e0d\u60f3\u91cd\u65b0\u8fd0\u884c\u6574\u4e2a\u811a\u672c\uff0c\u53ea\u60f3\u7528\u4e0d\u540c\u7684\u53c2\u6570\u6d4b\u8bd5\u67d0\u4e2a\u7a0b\u5f0f\u7684\u8bdd\uff0c\u8fd9\u4e2a\u7279\u6027\u663e\u5f97\u5c24\u5176\u5f3a\u5927\u3002\u4e0d\u8fc7\uff0c\u4f60\u4e5f\u53ef\u4ee5\u91cd\u65b0\u8ba1\u7b97\u6574\u4e2a notebook\uff0c\u53ea\u8981\u70b9\u51fb<code>Cell<\/code>\u00a0-&gt;\u00a0<code>Run all<\/code>\u5373\u53ef\u3002<\/p>\n<p>\u73b0\u5728\u6211\u4eec\u5df2\u7ecf\u77e5\u9053\u4e86\u5982\u4f55\u8f93\u5165\u4ee3\u7801\uff0c\u4e3a\u4ec0\u4e48\u4e0d\u5c1d\u8bd5\u7740\u8ba9\u8fd9\u4e2a notebook \u66f4\u52a0\u6f02\u4eae\u3001\u5185\u5bb9\u66f4\u4e30\u5bcc\uff1f\u4e3a\u6b64\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528\u5176\u4ed6\u7c7b\u578b\u7684\u5355\u5143\u683c\uff0c\u5373 Header\u5355\u5143\u683c\u548c Markdown\u5355\u5143\u683c\u3002<\/p>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u5728\u9876\u90e8\u6dfb\u52a0\u4e00\u4e2a notebook \u7684\u6807\u9898\u3002\u9009\u4e2d\u7b2c\u4e00\u4e2a\u5355\u5143\u683c\uff0c\u7136\u540e\u70b9\u51fb<code>Insert<\/code>\u00a0-&gt;\u00a0<code>Insert\u5355\u5143\u683cabove<\/code>\uff08\u5728\u4e0a\u65b9\u63d2\u5165\u5355\u5143\u683c\uff09\u3002\u4f60\u4f1a\u53d1\u73b0\uff0c\u6587\u6863\u7684\u9876\u90e8\u9a6c\u4e0a\u5c31\u51fa\u73b0\u4e86\u4e00\u4e2a\u65b0\u7684\u5355\u5143\u683c\u3002\u70b9\u51fb\u5728\u5feb\u6377\u952e\u680f\u4e2d\u7684\u5355\u5143\u683c\u7c7b\u578b\uff0c\u5c06\u5176\u53d8\u6210\u4e00\u4e2a\u6807\u9898\u5355\u5143\u683c\uff08heading cell\uff09\uff1a<\/p>\n<p><a href=\"https:\/\/yanjingang.com\/blog\/?attachment_id=1539\" rel=\"attachment wp-att-1539\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1539\" src=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/6.jpg\" alt=\"\" width=\"661\" height=\"30\" srcset=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/6.jpg 661w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/6-300x14.jpg 300w\" sizes=\"(max-width: 661px) 100vw, 661px\" \/><\/a><\/p>\n<p>\u9009\u4e2d\u4e0b\u62c9\u9009\u9879\u4e2d\u7684 Heading\u3002\u7136\u540e\u4f1a\u51fa\u73b0\u4e00\u4e2a\u5f39\u51fa\u6d88\u606f\uff0c\u544a\u8bc9\u4f60\u5982\u4f55\u521b\u5efa\u4e0d\u540c\u5c42\u7ea7\u7684\u6807\u9898\uff0c\u8fd9\u6837\u4f60\u5c31\u6709\u4e86\u4e00\u4e2a\u4e0d\u540c\u7c7b\u578b\u7684 cell\uff1a<\/p>\n<p><a href=\"https:\/\/yanjingang.com\/blog\/?attachment_id=1540\" rel=\"attachment wp-att-1540\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1540\" src=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/7.jpg\" alt=\"\" width=\"661\" height=\"113\" srcset=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/7.jpg 661w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/7-300x51.jpg 300w\" sizes=\"(max-width: 661px) 100vw, 661px\" \/><\/a><\/p>\n<p>\u8fd9\u4e2a\u5355\u5143\u683c\u4ee5<code>#<\/code>\u6807\u8bb0\u5f00\u5934\uff0c\u610f\u5473\u7740\u8fd9\u662f\u4e00\u4e2a\u4e00\u7ea7\u6807\u9898\u3002\u5982\u679c\u9700\u8981\u5b50\u6807\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6807\u8bb0\u8868\u793a\uff08\u6539\u53d8\u5355\u5143\u683c\u7c7b\u578b\u65f6\u5f39\u51fa\u6d88\u606f\u4e2d\u6709\u89e3\u91ca\uff09\uff1a<\/p>\n<div class=\"codehilite\">\n<pre># : \u4e00\u7ea7\u6807\u9898\n## : \u4e8c\u7ea7\u6807\u9898\n### : \u4e09\u7ea7\u6807\u9898\n...\n<\/pre>\n<\/div>\n<p>\u5728<code>#<\/code>\u4e4b\u540e\u5199\u4e0b\u6587\u6863\u7684\u6807\u9898\uff0c\u7136\u540e\u8ba1\u7b97\u8be5\u5355\u5143\u683c\u3002\u4f60\u4f1a\u53d1\u73b0\u4e00\u4e2a\u6837\u5f0f\u975e\u5e38\u597d\u770b\u7684\u6807\u9898\u3002\u4f5c\u4e3a\u793a\u4f8b\u548c\u7ec3\u4e60\uff0c\u6211\u8fd8\u6dfb\u52a0\u4e86\u5176\u4ed6\u51e0\u4e2a\u6807\u9898\u5355\u5143\u683c\uff1a<\/p>\n<p><a href=\"https:\/\/yanjingang.com\/blog\/?attachment_id=1541\" rel=\"attachment wp-att-1541\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1541\" src=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/8.jpg\" alt=\"\" width=\"661\" height=\"419\" srcset=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/8.jpg 661w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/8-300x190.jpg 300w\" sizes=\"(max-width: 661px) 100vw, 661px\" \/><\/a><\/p>\n<p>\u6dfb\u52a0\u597d\u6807\u9898\u4e4b\u540e\uff0c\u6211\u4eec\u5728\u7f16\u5199\u4e00\u4e9b\u89e3\u91ca\uff0c\u4ecb\u7ecd\u6bcf\u4e2a\u4ee3\u7801\u5355\u5143\u683c\u4e2d\u7684\u60c5\u51b5\u3002\u4e3a\u6b64\uff0c\u6211\u4eec\u8981\u5728\u76f8\u5e94\u7684\u5730\u65b9\u63d2\u5165\u5355\u5143\u683c\uff0c\u7136\u540e\u5c06\u5176\u7c7b\u578b\u53d8\u6210 Markdown\u3002\u7136\u540e\uff0c\u8ba1\u7b97\u65b0\u7684\u5355\u5143\u683c\u3002\u5c31\u8fd9\u6837\uff0c\u4f60\u7684\u89e3\u91ca\u6587\u672c\u5c31\u6f02\u4eae\u5730\u6e32\u67d3\u51fa\u6765\u4e86\uff01<\/p>\n<p><a href=\"https:\/\/yanjingang.com\/blog\/?attachment_id=1542\" rel=\"attachment wp-att-1542\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1542\" src=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/9.jpg\" alt=\"\" width=\"661\" height=\"497\" srcset=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/9.jpg 661w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/9-300x226.jpg 300w\" sizes=\"(max-width: 661px) 100vw, 661px\" \/><\/a><\/p>\n<p>\u6700\u540e\uff0c\u4f60\u53ef\u4ee5\u91cd\u547d\u540d\u8be5 notebook\uff0c\u70b9\u51fb<code>Fiel<\/code>\u00a0-&gt;\u00a0<code>Rename<\/code>\uff0c\u7136\u540e\u8f93\u5165\u65b0\u7684\u540d\u79f0\u3002\u8fd9\u6837\uff0c\u65b0\u7684\u540d\u79f0\u5c06\u4f1a\u51fa\u73b0\u5728\u7a97\u53e3\u7684\u5de6\u4e0a\u89d2\uff0c\u5728 Jupyter \u7684\u6807\u5fd7\u65c1\u8fb9\u3002<\/p>\n<h2 id=\"_1\">\u5355\u5143\u683c\u64cd\u4f5c<\/h2>\n<p>\u9ad8\u7ea7\u5355\u5143\u683c\u64cd\u4f5c\uff0c\u5c06\u8ba9\u7f16\u5199 notebook \u53d8\u5f97\u66f4\u52a0\u65b9\u4fbf\u3002\u4e3e\u4f8b\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>\u5982\u679c\u60f3\u5220\u9664\u67d0\u4e2a\u5355\u5143\u683c\uff0c\u53ef\u4ee5\u9009\u62e9\u8be5\u5355\u5143\u683c\uff0c\u7136\u540e\u4f9d\u6b21\u70b9\u51fb<code>Edit<\/code>\u00a0-&gt;\u00a0<code>Delete Cell<\/code>\uff1b<\/li>\n<li>\u5982\u679c\u60f3\u79fb\u52a8\u67d0\u4e2a\u5355\u5143\u683c\uff0c\u53ea\u9700\u8981\u4f9d\u6b21\u70b9\u51fb<code>Edit<\/code>\u00a0-&gt;\u00a0<code>Move cell [up | down]<\/code>\uff1b<\/li>\n<li>\u5982\u679c\u60f3\u526a\u8d34\u67d0\u4e2a\u5355\u5143\u6d4b\uff0c\u53ef\u4ee5\u5148\u70b9\u51fb<code>Edit<\/code>\u00a0-&gt;\u00a0<code>Cut Cell<\/code>\uff0c\u7136\u540e\u5728\u70b9\u51fb<code>Edit<\/code>\u00a0-&gt;\u00a0<code>Paste Cell [Above | Below]<\/code>\uff1b<\/li>\n<li>\u5982\u679c\u4f60\u7684 notebook \u4e2d\u6709\u5f88\u591a\u5355\u5143\u683c\u53ea\u9700\u8981\u6267\u884c\u4e00\u6b21\uff0c\u6216\u8005\u60f3\u4e00\u6b21\u6027\u6267\u884c\u5927\u6bb5\u4ee3\u7801\uff0c\u90a3\u4e48\u53ef\u4ee5\u9009\u62e9\u5408\u5e76\u8fd9\u4e9b\u5355\u5143\u683c\u3002\u70b9\u51fb<code>Edit<\/code>\u00a0-&gt;\u00a0<code>Merge Cell [Above | below]<\/code>\u3002<\/li>\n<\/ul>\n<p>\u8bb0\u4f4f\u8fd9\u4e9b\u64cd\u4f5c\uff0c\u5b83\u4eec\u53ef\u4ee5\u5e2e\u52a9\u4f60\u8282\u7701\u8bb8\u591a\u65f6\u95f4\u3002<\/p>\n<h2 id=\"markdown\">Markdown \u5355\u5143\u683c\u9ad8\u7ea7\u7528\u6cd5<\/h2>\n<p>\u6211\u4eec\u518d\u6765\u770b\u770b Markdown \u5355\u5143\u683c\u3002\u867d\u7136\u5b83\u7684\u7c7b\u578b\u662f markdown\uff0c\u4f46\u662f\u8fd9\u7c7b\u5355\u5143\u683c\u4e5f\u63a5\u53d7 HTML \u4ee3\u7801\u3002\u8fd9\u6837\uff0c\u4f60\u5c31\u53ef\u4ee5\u5728\u5355\u5143\u683c\u7c7b\u5b9e\u73b0\u66f4\u52a0\u4e30\u5bcc\u7684\u6837\u5f0f\uff0c\u6dfb\u52a0\u56fe\u7247\uff0c\u7b49\u7b49\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60f3\u5728 notebook \u4e2d\u6dfb\u52a0 Jupyter \u7684 logo\uff0c\u5c06\u5176\u5927\u5c0f\u8bbe\u7f6e\u4e3a 100px x 100px\uff0c\u5e76\u4e14\u653e\u7f6e\u5728\u5355\u5143\u683c\u5de6\u4fa7\uff0c\u53ef\u4ee5\u8fd9\u6837\u7f16\u5199\uff1a<\/p>\n<div class=\"codehilite\">\n<pre><span class=\"nt\">&lt;img <span class=\"na\">src=<span class=\"s\">\"http:\/\/blog.jupyter.org\/content\/images\/2015\/02\/jupyter-sq-text.png\"\nstyle=\"width:100px;height:100px;float:left\"&gt;\n<\/span><\/span><\/span><\/pre>\n<\/div>\n<p>\u8ba1\u7b97\u8be5\u5355\u5143\u683c\u4e4b\u540e\uff0c\u4f1a\u51fa\u73b0\u8fd9\u6837\u7684\u7ed3\u679c\uff1a<\/p>\n<p><a href=\"https:\/\/yanjingang.com\/blog\/?attachment_id=1543\" rel=\"attachment wp-att-1543\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1543\" src=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/10.png\" alt=\"\" width=\"661\" height=\"164\" srcset=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/10.png 661w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/10-300x74.png 300w\" sizes=\"(max-width: 661px) 100vw, 661px\" \/><\/a><\/p>\n<p>\u53e6\u5916\uff0cmarkdown \u5355\u5143\u683c\u8fd8\u652f\u6301 LaTex \u8bed\u6cd5\u3002\u4f8b\u5982\uff1a<\/p>\n<div class=\"codehilite\">\n<pre>$\\int_0^{+\\infty} x^2 dx$\n<\/pre>\n<\/div>\n<p>\u8ba1\u7b97\u4e0a\u8ff0\u5355\u5143\u683c\uff0c\u5c06\u83b7\u5f97\u4e0b\u9762\u7684 LaTex \u65b9\u7a0b\u5f0f\uff1a<\/p>\n<p><a href=\"https:\/\/yanjingang.com\/blog\/?attachment_id=1544\" rel=\"attachment wp-att-1544\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1544\" src=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/11.png\" alt=\"\" width=\"661\" height=\"120\" srcset=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/11.png 661w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/11-300x54.png 300w\" sizes=\"(max-width: 661px) 100vw, 661px\" \/><\/a><\/p>\n<h2 id=\"_2\">\u5bfc\u51fa\u529f\u80fd<\/h2>\n<p>notebook \u8fd8\u6709\u4e00\u4e2a\u5f3a\u5927\u7684\u7279\u6027\uff0c\u5c31\u662f\u5176\u5bfc\u51fa\u529f\u80fd\u3002\u53ef\u4ee5\u5c06 notebook \u5bfc\u51fa\u4e3a\u591a\u79cd\u683c\u5f0f\uff1a<\/p>\n<ul>\n<li>HTML<\/li>\n<li>Markdown<\/li>\n<li>ReST<\/li>\n<li>PDF\uff08\u901a\u8fc7 LaTeX\uff09<\/li>\n<li>Raw Python<\/li>\n<\/ul>\n<p>\u5bfc\u51fa PDF \u529f\u80fd\uff0c\u53ef\u4ee5\u8ba9\u4f60\u4e0d\u7528\u5199 LaTex \u5373\u53ef\u521b\u5efa\u6f02\u4eae\u7684 PDF \u6587\u6863\u3002\u4f60\u8fd8\u53ef\u4ee5\u5c06 notebook \u4f5c\u4e3a\u7f51\u9875\u53d1\u5e03\u5728\u4f60\u7684\u7f51\u7ad9\u4e0a\u3002\u751a\u81f3\uff0c\u4f60\u53ef\u4ee5\u5bfc\u51fa\u4e3a ReST \u683c\u5f0f\uff0c\u4f5c\u4e3a\u8f6f\u4ef6\u5e93\u7684\u6587\u6863\u3002<\/p>\n<h2 id=\"matplotlib\">Matplotlib \u96c6\u6210<\/h2>\n<p>\u5982\u679c\u4f60\u7528 Python \u7ed8\u5236\u8fc7\u56fe\u5f62\uff0c\u90a3\u4f60\u80af\u5b9a\u77e5\u9053 matplotlib\u3002Matplotlib \u662f\u4e00\u4e2a\u7528\u4e8e\u521b\u5efa\u6f02\u4eae\u56fe\u5f62\u7684 Python \u5e93\uff0c\u7ed3\u5408 Jupyter notebook \u4f7f\u7528\u65f6\u4f53\u9a8c\u66f4\u4f73\u3002<\/p>\n<p>\u8981\u60f3\u5728 Jupyter notebook \u4e2d\u4f7f\u7528 matplotlib\uff0c\u9700\u8981\u544a\u8bc9 Jupyter \u83b7\u53d6 matplotlib \u751f\u6210\u7684\u6240\u6709\u56fe\u5f62\uff0c\u5e76\u5c06\u5176\u5d4c\u5165 notebook \u4e2d\u3002\u4e3a\u6b64\uff0c\u9700\u8981\u8ba1\u7b97\uff1a<\/p>\n<div class=\"codehilite\">\n<pre><span class=\"nf\">%matplotlib <span class=\"kr\">inline\n<\/span><\/span><\/pre>\n<\/div>\n<blockquote><p>\u8bd1\u6ce8\uff1a\u8981\u60f3\u6267\u884c\u6210\u529f\uff0c\u9700\u8981\u5148<code>pip install matplotlib<\/code>\u3002<\/p><\/blockquote>\n<p>\u8fd0\u884c\u8fd9\u4e2a\u6307\u4ee4\u53ef\u80fd\u8981\u82b1\u4e2a\u51e0\u79d2\u949f\uff0c\u4f46\u662f\u5728 notebook \u4e2d\u9700\u8981\u6267\u884c\u4e00\u6b21\u5373\u53ef\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u6765\u7ed8\u5236\u4e00\u4e2a\u56fe\u5f62\uff0c\u770b\u770b\u5177\u4f53\u7684\u96c6\u6210\u6548\u679c\uff1a<\/p>\n<div class=\"codehilite\">\n<pre><span class=\"kn\">import <span class=\"nn\">matplotlib.pyplot as plt\nimport numpy as np\n\n<span class=\"n\">x <span class=\"o\">= np.arange<span class=\"p\">(<span class=\"mi\">20)\ny = x**2\n\nplt.plot(x, y)\n<\/span><\/span><\/span><\/span><\/span><\/span><\/pre>\n<\/div>\n<p>\u4e0a\u9762\u7684\u4ee3\u7801\u5c06\u7ed8\u5236\u65b9\u7a0b\u5f0f y=x^2 \u3002\u8ba1\u7b97\u5355\u5143\u683c\u540e\uff0c\u4f1a\u5f97\u5230\u5982\u4e0b\u56fe\u5f62\uff1a<\/p>\n<p><a href=\"https:\/\/yanjingang.com\/blog\/?attachment_id=1545\" rel=\"attachment wp-att-1545\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1545\" src=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/12.png\" alt=\"\" width=\"661\" height=\"504\" srcset=\"https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/12.png 661w, https:\/\/yanjingang.com\/blog\/wp-content\/uploads\/2018\/04\/12-300x229.png 300w\" sizes=\"(max-width: 661px) 100vw, 661px\" \/><\/a><\/p>\n<p>\u6211\u4eec\u770b\u5230\uff0c\u7ed8\u5236\u51fa\u7684\u56fe\u5f62\u76f4\u63a5\u6dfb\u52a0\u5728\u4e86 notebook \u4e2d\uff0c\u5c31\u5728\u4ee3\u7801\u7684\u4e0b\u9762\u3002\u6211\u4eec\u53ef\u4ee5\u4e4b\u540e\u4fee\u6539\u4ee3\u7801\uff0c\u91cd\u65b0\u8ba1\u7b97\uff0c\u8fd9\u65f6\u56fe\u5f62\u4e5f\u4f1a\u52a8\u6001\u66f4\u65b0\u3002\u8fd9\u662f\u6bcf\u4e2a\u6570\u636e\u79d1\u5b66\u5bb6\u90fd\u60f3\u8981\u7684\u4e00\u4e2a\u7279\u6027\uff1a\u5c06\u4ee3\u7801\u548c\u56fe\u7247\u653e\u5728\u540c\u4e00\u4e2a\u6587\u4ef6\u4e2d\uff0c\u6e05\u695a\u5730\u770b\u51fa\u6bcf\u6bb5\u4ee3\u7801\u7684\u6548\u679c\u3002<\/p>\n<h2 id=\"_3\">\u975e\u672c\u5730\u5185\u6838<\/h2>\n<p>\u6211\u4eec\u53ef\u4ee5\u975e\u5e38\u5bb9\u6613\u5730\u5728\u4e00\u53f0\u7535\u8111\u4e0a\u542f\u52a8 Jupyter\uff0c\u800c\u4e14\u652f\u6301\u591a\u4eba\u901a\u8fc7\u7f51\u7edc\u8fde\u63a5\u540c\u4e00\u4e2a Jupyter \u5b9e\u4f8b\u3002\u5728\u4e0a\u4e00\u7bc7\u6587\u7ae0\u4e2d\uff0c\u4f60\u6709\u6ca1\u6709\u6ce8\u610f\u542f\u52a8 Jupyter \u65f6\u51fa\u73b0\u8fc7\u8fd9\u6837\u4e00\u6bb5\u8bdd\uff1a<\/p>\n<div class=\"codehilite\">\n<pre>The IPython Notebook is running at: http:\/\/localhost:8888\/\n<\/pre>\n<\/div>\n<p>\u8fd9\u610f\u5473\u7740\uff0c\u4f60\u7684 notebook \u662f\u672c\u5730\u8fd0\u884c\u7684\uff0c\u53ef\u4ee5\u5728\u6d4f\u89c8\u5668\u4e0a\u6253\u5f00 http:\/\/localhost:8888\/ \uff0c\u4ece\u800c\u8bbf\u95ee notebook\u3002\u4f60\u4e5f\u53ef\u4ee5\u4fee\u6539\u4e0b\u914d\u7f6e\uff0c\u8ba9\u8be5 notebook \u53ef\u4ee5\u88ab\u516c\u5f00\u8bbf\u95ee\u3002\u8fd9\u6837\uff0c\u4efb\u4f55\u77e5\u9053 notebook \u5730\u5740\u7684\u4eba\u90fd\u53ef\u4ee5\u8fde\u63a5\u5230 notebook \u8fdb\u884c\u8fdc\u7a0b\u4fee\u6539\u3002<\/p>\n<h2 id=\"_4\">\u7ed3\u8bed<\/h2>\n<p>\u4ece\u8fd9\u4e24\u7bc7\u5feb\u901f\u5165\u95e8\u4ecb\u7ecd\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff1aJupyter notebook \u662f\u4e00\u4e2a\u975e\u5e38\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u521b\u5efa\u6f02\u4eae\u7684\u4ea4\u4e92\u5f0f\u6587\u6863\uff0c\u5236\u4f5c\u6559\u5b66\u6750\u6599\uff0c\u7b49\u7b49\u3002\u5efa\u8bae\u4f60\u9a6c\u4e0a\u5f00\u59cb\u4f7f\u7528 Jupyter notebook\uff0c\u63a2\u7d22\u66f4\u591a notebook \u7684\u5f3a\u5927\u529f\u80fd\u3002<\/p>\n<p><span style=\"color: #808080;\">\u539f\u6587\uff1ahttps:\/\/www.packtpub.com\/books\/content\/getting-started-jupyter-notebook-part-1<\/span><\/p>\n<p><span style=\"color: #808080;\">\u6458\u81ea\uff1ahttps:\/\/www.cnblogs.com\/nxld\/p\/6566380.html<\/span><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Jupyter Notebook\uff08\u6b64\u524d\u88ab\u79f0\u4e3a IPython notebook\uff09\u662f\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u7b14\u8bb0\u672c\uff0c\u652f\u6301\u8fd0\u884c 40 \u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd Jupyter notebook \u7684\u4e3b\u8981\u7279\u6027\uff0c\u4ee5\u53ca\u4e3a\u4ec0\u4e48\u5bf9\u4e8e\u5e0c\u671b\u7f16\u5199\u6f02\u4eae\u7684\u4ea4\u4e92\u5f0f\u6587\u6863\u7684\u4eba\u6765\u8bf4\u662f\u4e00\u4e2a\u5f3a\u5927\u5de5\u5177\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[255,77],"tags":[546,547],"_links":{"self":[{"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1533"}],"collection":[{"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1533"}],"version-history":[{"count":0,"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1533\/revisions"}],"wp:attachment":[{"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}