{"id":1014972,"date":"2024-12-27T12:01:07","date_gmt":"2024-12-27T04:01:07","guid":{"rendered":""},"modified":"2024-12-27T12:01:09","modified_gmt":"2024-12-27T04:01:09","slug":"jupyter%e5%a6%82%e4%bd%95%e7%bc%96%e8%be%91python%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1014972.html","title":{"rendered":"jupyter\u5982\u4f55\u7f16\u8f91python\u6587\u4ef6"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25094937\/bc4deaf9-28fc-4ad8-b3ea-b5e907a2f51c.webp\" alt=\"jupyter\u5982\u4f55\u7f16\u8f91python\u6587\u4ef6\" \/><\/p>\n<p><p> <strong>\u5728Jupyter\u4e2d\u7f16\u8f91Python\u6587\u4ef6\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528\u5185\u7f6e\u6587\u672c\u7f16\u8f91\u5668\u3001\u901a\u8fc7\u7b14\u8bb0\u672c\u7f16\u8f91\u3001\u7ed3\u5408\u5916\u90e8IDE\u4f7f\u7528\u3002<\/strong> \u5728\u8fd9\u4e9b\u65b9\u6cd5\u4e2d\uff0c\u4f7f\u7528Jupyter\u7684\u5185\u7f6e\u6587\u672c\u7f16\u8f91\u5668\u662f\u6700\u76f4\u63a5\u7684\u65b9\u5f0f\uff0c\u56e0\u4e3a\u5b83\u5141\u8bb8\u7528\u6237\u5728\u540c\u4e00\u73af\u5883\u4e2d\u7ba1\u7406\u548c\u7f16\u8f91\u811a\u672c\u6587\u4ef6\u3002\u800c\u901a\u8fc7Jupyter Notebook\u7f16\u8f91Python\u6587\u4ef6\u5219\u63d0\u4f9b\u4e86\u4e00\u79cd\u4ea4\u4e92\u5f0f\u7684\u65b9\u5f0f\u6765\u8fd0\u884c\u548c\u8c03\u8bd5\u4ee3\u7801\uff0c\u9002\u5408\u6570\u636e\u5206\u6790\u548c\u6570\u636e\u79d1\u5b66\u5de5\u4f5c\u3002\u7ed3\u5408\u5916\u90e8IDE\uff0c\u5982VSCode\u6216PyCharm\uff0c\u53ef\u4ee5\u63d0\u4f9b\u66f4\u9ad8\u7ea7\u7684\u529f\u80fd\u548c\u63d2\u4ef6\u652f\u6301\uff0c\u9002\u5408\u5927\u578b\u9879\u76ee\u5f00\u53d1\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528Jupyter\u5185\u7f6e\u6587\u672c\u7f16\u8f91\u5668<\/h3>\n<\/p>\n<p><p>Jupyter Notebook\u4e0d\u4ec5\u4ec5\u7528\u4e8e\u4ea4\u4e92\u5f0f\u8ba1\u7b97\uff0c\u5b83\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e2a\u57fa\u672c\u7684\u6587\u672c\u7f16\u8f91\u5668\uff0c\u53ef\u4ee5\u7f16\u8f91Python\u6587\u4ef6\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u4f7f\u7528Jupyter\u7684\u6587\u672c\u7f16\u8f91\u5668\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6253\u5f00Jupyter Notebook\uff1a<\/strong> \u9996\u5148\uff0c\u542f\u52a8\u4f60\u7684Jupyter Notebook\uff0c\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165<code>jupyter notebook<\/code>\u3002\u8fd9\u5c06\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u6d4f\u89c8\u5668\u7a97\u53e3\u6216\u9009\u9879\u5361\uff0c\u663e\u793aJupyter\u7684\u6587\u4ef6\u6d4f\u89c8\u5668\u754c\u9762\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u521b\u5efa\u6216\u7f16\u8f91Python\u6587\u4ef6\uff1a<\/strong> \u5728\u6587\u4ef6\u6d4f\u89c8\u5668\u4e2d\uff0c\u70b9\u51fb\u201cNew\u201d\u6309\u94ae\uff0c\u5728\u4e0b\u62c9\u83dc\u5355\u4e2d\u9009\u62e9\u201cText File\u201d\u3002\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6587\u672c\u6587\u4ef6\u3002\u4f60\u53ef\u4ee5\u5c06\u5176\u91cd\u547d\u540d\u4e3a\u4ee5<code>.py<\/code>\u7ed3\u5c3e\u4ee5\u8868\u660e\u5b83\u662f\u4e00\u4e2aPython\u6587\u4ef6\u3002\u8981\u7f16\u8f91\u73b0\u6709\u7684Python\u6587\u4ef6\uff0c\u53ea\u9700\u5728\u6587\u4ef6\u6d4f\u89c8\u5668\u4e2d\u70b9\u51fb\u6587\u4ef6\u540d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7f16\u8f91\u548c\u4fdd\u5b58\uff1a<\/strong> \u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u6765\u8f93\u5165\u6216\u7f16\u8f91Python\u4ee3\u7801\u3002\u7f16\u8f91\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u201cFile\u201d\u83dc\u5355\uff0c\u7136\u540e\u9009\u62e9\u201cSave\u201d\u6765\u4fdd\u5b58\u66f4\u6539\u3002\u6587\u672c\u7f16\u8f91\u5668\u63d0\u4f9b\u57fa\u672c\u7684\u8bed\u6cd5\u9ad8\u4eae\uff0c\u4f46\u4e0d\u5982\u4e13\u7528IDE\u90a3\u6837\u5f3a\u5927\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884cPython\u6587\u4ef6\uff1a<\/strong> \u5728Jupyter Notebook\u4e2d\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u7ec8\u7aef\u6216Notebook\u5355\u5143\u6765\u8fd0\u884cPython\u6587\u4ef6\u3002\u5728\u6587\u4ef6\u6d4f\u89c8\u5668\u4e2d\uff0c\u9009\u62e9\u201cNew\u201d-&gt;\u201cTerminal\u201d\uff0c\u7136\u540e\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python filename.py<\/code>\u6765\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u901a\u8fc7Jupyter Notebook\u7f16\u8f91Python\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>Jupyter Notebook\u4ee5\u5176\u4ea4\u4e92\u6027\u800c\u95fb\u540d\uff0c\u975e\u5e38\u9002\u5408\u6570\u636e\u5206\u6790\u548c\u63a2\u7d22\u6027\u7f16\u7a0b\u3002\u867d\u7136\u5b83\u4e3b\u8981\u8bbe\u8ba1\u7528\u4e8e\u4ea4\u4e92\u5f0f\u5355\u5143\uff0c\u4f46\u4f60\u53ef\u4ee5\u7528\u5b83\u6765\u7f16\u8f91\u548c\u6267\u884cPython\u4ee3\u7801\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efaNotebook\uff1a<\/strong> \u5728Jupyter\u7684\u6587\u4ef6\u6d4f\u89c8\u5668\u4e2d\uff0c\u70b9\u51fb\u201cNew\u201d\u6309\u94ae\uff0c\u9009\u62e9\u201cPython 3\u201d\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Notebook\u3002\u8fd9\u5c06\u6253\u5f00\u4e00\u4e2a\u65b0\u7684Notebook\u754c\u9762\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7f16\u8f91\u4ee3\u7801\u5355\u5143\uff1a<\/strong> \u6bcf\u4e2aNotebook\u7531\u591a\u4e2a\u5355\u5143\u7ec4\u6210\uff0c\u60a8\u53ef\u4ee5\u5728\u5176\u4e2d\u8f93\u5165\u548c\u7f16\u8f91Python\u4ee3\u7801\u3002\u5355\u51fb\u5355\u5143\u5e76\u5f00\u59cb\u8f93\u5165\u4ee3\u7801\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u70b9\u51fb\u5de5\u5177\u680f\u4e0a\u7684\u201cRun\u201d\u6309\u94ae\u6765\u8fd0\u884c\u5355\u5143\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8c03\u8bd5\u548c\u6d4b\u8bd5\u4ee3\u7801\uff1a<\/strong> Jupyter Notebook\u7684\u4ea4\u4e92\u6027\u5141\u8bb8\u4f60\u9010\u6b65\u8c03\u8bd5\u548c\u6d4b\u8bd5\u4ee3\u7801\u3002\u4f60\u53ef\u4ee5\u8fd0\u884c\u4e00\u4e2a\u5355\u5143\uff0c\u7136\u540e\u7acb\u5373\u67e5\u770b\u8f93\u51fa\u3002\u5bf9\u4e8e\u6570\u636e\u5206\u6790\u548c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u9879\u76ee\uff0c\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u5f3a\u5927\u7684\u529f\u80fd\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4fdd\u5b58Notebook\uff1a<\/strong> Jupyter Notebook\u4f1a\u81ea\u52a8\u4fdd\u5b58\u4f60\u7684\u5de5\u4f5c\uff0c\u4f46\u4f60\u4e5f\u53ef\u4ee5\u901a\u8fc7\u201cFile\u201d\u83dc\u5355\u624b\u52a8\u4fdd\u5b58\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u7ed3\u5408\u5916\u90e8IDE\u4f7f\u7528Jupyter<\/h3>\n<\/p>\n<p><p>\u5c3d\u7ba1Jupyter\u63d0\u4f9b\u4e86\u4e00\u4e9b\u57fa\u672c\u7684\u6587\u672c\u7f16\u8f91\u529f\u80fd\uff0c\u4f46\u8bb8\u591a\u5f00\u53d1\u8005\u66f4\u559c\u6b22\u4f7f\u7528\u529f\u80fd\u66f4\u5f3a\u5927\u7684IDE\uff0c\u5982VSCode\u6216PyCharm\u3002\u8fd9\u4e9bIDE\u63d0\u4f9b\u4e86\u66f4\u9ad8\u7ea7\u7684\u4ee3\u7801\u7f16\u8f91\u529f\u80fd\uff0c\u5982\u81ea\u52a8\u8865\u5168\u3001\u8c03\u8bd5\u5de5\u5177\u548c\u63d2\u4ef6\u652f\u6301\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Jupyter\u63d2\u4ef6\uff1a<\/strong> \u5728VSCode\u4e2d\uff0c\u4f60\u53ef\u4ee5\u5b89\u88c5Jupyter\u63d2\u4ef6\u6765\u76f4\u63a5\u5728VSCode\u4e2d\u8fd0\u884c\u548c\u7f16\u8f91Notebook\u3002\u6253\u5f00VSCode\u7684\u6269\u5c55\u5546\u5e97\uff0c\u641c\u7d22\u5e76\u5b89\u88c5\u201cJupyter\u201d\u6269\u5c55\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6253\u5f00\u5e76\u7f16\u8f91Python\u6587\u4ef6\uff1a<\/strong> \u5728VSCode\u4e2d\u6253\u5f00Python\u6587\u4ef6\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528IDE\u7684\u5f3a\u5927\u529f\u80fd\u6765\u7f16\u8f91\u4ee3\u7801\u3002VSCode\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u63d2\u4ef6\u652f\u6301\u548c\u914d\u7f6e\u9009\u9879\uff0c\u53ef\u4ee5\u6781\u5927\u5730\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4e0eJupyter\u96c6\u6210\uff1a<\/strong> \u901a\u8fc7Jupyter\u63d2\u4ef6\uff0c\u4f60\u53ef\u4ee5\u5728VSCode\u4e2d\u8fd0\u884cNotebook\uff0c\u67e5\u770b\u8f93\u51fa\uff0c\u5e76\u4e0eJupyter\u73af\u5883\u65e0\u7f1d\u96c6\u6210\u3002\u8fd9\u4f7f\u5f97\u5728\u540c\u4e00\u5de5\u5177\u4e2d\u8fdb\u884c\u5f00\u53d1\u548c\u6570\u636e\u5206\u6790\u6210\u4e3a\u53ef\u80fd\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8c03\u8bd5\u548c\u7248\u672c\u63a7\u5236\uff1a<\/strong> \u5916\u90e8IDE\u901a\u5e38\u5177\u6709\u5f3a\u5927\u7684\u8c03\u8bd5\u5de5\u5177\u548c\u5185\u7f6e\u7684\u7248\u672c\u63a7\u5236\u652f\u6301\uff08\u5982Git\uff09\uff0c\u8fd9\u5bf9\u5927\u578b\u9879\u76ee\u7684\u5f00\u53d1\u548c\u7ba1\u7406\u975e\u5e38\u6709\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u5728Jupyter\u4e2d\u4f7f\u7528\u9b54\u672f\u547d\u4ee4<\/h3>\n<\/p>\n<p><p>Jupyter Notebook\u4e2d\u6709\u4e00\u7ec4\u7279\u6b8a\u7684\u547d\u4ee4\uff0c\u79f0\u4e3a\u201c\u9b54\u672f\u547d\u4ee4\u201d\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5728Notebook\u4e2d\u66f4\u6709\u6548\u5730\u7f16\u5199\u548c\u8fd0\u884c\u4ee3\u7801\u3002\u5176\u4e2d\u4e00\u4e9b\u547d\u4ee4\u53ef\u4ee5\u76f4\u63a5\u7528\u4e8e\u7ba1\u7406Python\u6587\u4ef6\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8fd0\u884cPython\u811a\u672c\uff1a<\/strong> \u4f7f\u7528<code>%run filename.py<\/code>\u9b54\u672f\u547d\u4ee4\u53ef\u4ee5\u76f4\u63a5\u5728Notebook\u5355\u5143\u4e2d\u8fd0\u884cPython\u811a\u672c\u3002\u8fd9\u5bf9\u4e8e\u9700\u8981\u9891\u7e41\u6d4b\u8bd5\u548c\u8c03\u8bd5\u7684\u4ee3\u7801\u6bb5\u7279\u522b\u6709\u7528\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u65f6\u95f4\u548c\u6027\u80fd\u5206\u6790\uff1a<\/strong> \u4f7f\u7528<code>%time<\/code>\u548c<code>%timeit<\/code>\u9b54\u672f\u547d\u4ee4\u53ef\u4ee5\u6d4b\u91cf\u4ee3\u7801\u6267\u884c\u7684\u65f6\u95f4\uff0c\u5e2e\u52a9\u4f60\u8bc6\u522b\u6027\u80fd\u74f6\u9888\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5bfc\u5165\u5916\u90e8\u811a\u672c\uff1a<\/strong> \u901a\u8fc7<code>%load filename.py<\/code>\u547d\u4ee4\u53ef\u4ee5\u5c06\u5916\u90e8Python\u811a\u672c\u7684\u5185\u5bb9\u52a0\u8f7d\u5230\u5f53\u524d\u5355\u5143\u4e2d\u8fdb\u884c\u7f16\u8f91\u3002\u8fd9\u975e\u5e38\u6709\u52a9\u4e8e\u91cd\u7528\u548c\u4fee\u6539\u73b0\u6709\u4ee3\u7801\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u7248\u672c\u63a7\u5236\u548c\u534f\u4f5c<\/h3>\n<\/p>\n<p><p>\u5728\u5927\u578b\u9879\u76ee\u4e2d\uff0c\u7248\u672c\u63a7\u5236\u548c\u534f\u4f5c\u662f\u5173\u952e\u3002\u867d\u7136Jupyter Notebook\u4e0d\u76f4\u63a5\u652f\u6301\u7248\u672c\u63a7\u5236\uff0c\u4f46\u4f60\u53ef\u4ee5\u4f7f\u7528Git\u6765\u7ba1\u7406Python\u6587\u4ef6\u548cNotebook\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528Git\u7ba1\u7406\u6587\u4ef6\uff1a<\/strong> \u5728\u4f60\u7684\u9879\u76ee\u76ee\u5f55\u4e2d\u521d\u59cb\u5316Git\u4ed3\u5e93\uff0c\u5e76\u5c06Python\u6587\u4ef6\u548cNotebook\u6dfb\u52a0\u5230\u7248\u672c\u63a7\u5236\u4e2d\u3002\u901a\u8fc7\u5b9a\u671f\u63d0\u4ea4\u66f4\u6539\uff0c\u4f60\u53ef\u4ee5\u8ddf\u8e2a\u9879\u76ee\u7684\u6f14\u53d8\u5e76\u8f7b\u677e\u56de\u6eda\u5230\u4ee5\u524d\u7684\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u534f\u4f5c\u5f00\u53d1\uff1a<\/strong> \u4f7f\u7528Git\u548cGitHub\u7b49\u5e73\u53f0\uff0c\u56e2\u961f\u6210\u5458\u53ef\u4ee5\u534f\u4f5c\u5f00\u53d1\uff0c\u63d0\u4ea4\u62c9\u53d6\u8bf7\u6c42\u5e76\u8fdb\u884c<a href=\"https:\/\/docs.pingcode.com\/code-review\" target=\"_blank\">\u4ee3\u7801\u5ba1\u67e5<\/a>\u3002\u8fd9\u5bf9\u5206\u5e03\u5f0f\u56e2\u961f\u5c24\u5176\u6709\u7528\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7ba1\u7406Notebook\uff1a<\/strong> \u7531\u4e8eJupyter Notebook\u7684JSON\u683c\u5f0f\u5bf9\u7248\u672c\u63a7\u5236\u4e0d\u53cb\u597d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>nbdime<\/code>\u5de5\u5177\u66f4\u597d\u5730\u6bd4\u8f83\u548c\u5408\u5e76Notebook\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u516d\u3001\u81ea\u52a8\u5316\u548c\u811a\u672c\u5316\u5de5\u4f5c\u6d41\u7a0b<\/h3>\n<\/p>\n<p><p>\u5728Jupyter\u4e2d\u5904\u7406\u6570\u636e\u548c\u5206\u6790\u65f6\uff0c\u81ea\u52a8\u5316\u548c\u811a\u672c\u5316\u53ef\u4ee5\u6781\u5927\u5730\u63d0\u9ad8\u6548\u7387\u548c\u91cd\u7528\u6027\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528\u811a\u672c\u81ea\u52a8\u5316\u5206\u6790\uff1a<\/strong> \u5c06\u6570\u636e\u5206\u6790\u8fc7\u7a0b\u5199\u6210Python\u811a\u672c\uff0c\u5e76\u901a\u8fc7Jupyter Notebook\u4e2d\u7684\u7ec8\u7aef\u6216\u5916\u90e8\u8c03\u5ea6\u5de5\u5177\uff08\u5982cron\uff09\u81ea\u52a8\u5316\u8fd0\u884c\u3002\u8fd9\u51cf\u5c11\u4e86\u624b\u52a8\u6267\u884c\u7684\u9700\u6c42\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u53c2\u6570\u5316Notebook\uff1a<\/strong> \u4f7f\u7528\u5de5\u5177\uff08\u5982papermill\uff09\u53ef\u4ee5\u4e3aNotebook\u6dfb\u52a0\u53c2\u6570\uff0c\u4f7f\u5176\u6210\u4e3a\u53ef\u91cd\u7528\u7684\u5206\u6790\u6a21\u677f\u3002\u901a\u8fc7\u4e0d\u540c\u7684\u53c2\u6570\u503c\uff0cNotebook\u53ef\u4ee5\u6267\u884c\u4e0d\u540c\u7684\u5206\u6790\u4efb\u52a1\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u96c6\u6210\u5de5\u4f5c\u6d41\uff1a<\/strong> \u7ed3\u5408\u5176\u4ed6\u5de5\u5177\uff08\u5982Apache <a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>rflow\u6216Luigi\uff09\uff0c\u53ef\u4ee5\u521b\u5efa\u590d\u6742\u7684\u6570\u636e\u5de5\u4f5c\u6d41\uff0c\u81ea\u52a8\u5316\u6574\u4e2a\u6570\u636e\u7ba1\u9053\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u8fd9\u4e9b\u65b9\u6cd5\u548c\u5de5\u5177\uff0cJupyter\u4e0d\u4ec5\u4ec5\u662f\u4e00\u4e2a\u7528\u4e8e\u6570\u636e\u5206\u6790\u548c\u5b66\u4e60\u7684\u5e73\u53f0\uff0c\u5b83\u8fd8\u53ef\u4ee5\u6210\u4e3aPython\u5f00\u53d1\u5de5\u4f5c\u6d41\u7a0b\u7684\u6838\u5fc3\u3002\u65e0\u8bba\u662f\u7b80\u5355\u7684\u811a\u672c\u7f16\u8f91\u8fd8\u662f\u590d\u6742\u7684\u6570\u636e\u7ba1\u9053\uff0cJupyter\u90fd\u63d0\u4f9b\u4e86\u7075\u6d3b\u548c\u5f3a\u5927\u7684\u652f\u6301\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Jupyter\u4e2d\u521b\u5efa\u65b0\u7684Python\u6587\u4ef6\uff1f<\/strong><br \/>\u5728Jupyter Notebook\u4e2d\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u70b9\u51fb\u754c\u9762\u9876\u90e8\u7684\u201c\u65b0\u5efa\u201d\u6309\u94ae\uff0c\u9009\u62e9\u201cPython 3\u201d\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python Notebook\u6587\u4ef6\u3002\u521b\u5efa\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u65b0\u7684\u5355\u5143\u4e2d\u8f93\u5165Python\u4ee3\u7801\uff0c\u5e76\u901a\u8fc7\u6309\u4e0bShift + Enter\u6765\u6267\u884c\u4ee3\u7801\u3002\u82e5\u60f3\u4ee5.py\u683c\u5f0f\u4fdd\u5b58\u4ee3\u7801\uff0c\u53ef\u4ee5\u901a\u8fc7\u201c\u6587\u4ef6\u201d\u83dc\u5355\u9009\u62e9\u201c\u4e0b\u8f7d\u4e3a\u201d\uff0c\u7136\u540e\u9009\u62e9Python\u6587\u4ef6\u683c\u5f0f\u3002<\/p>\n<p><strong>Jupyter Notebook\u4e0eJupyter Lab\u6709\u4ec0\u4e48\u533a\u522b\uff0c\u54ea\u4e2a\u66f4\u9002\u5408\u7f16\u8f91Python\u6587\u4ef6\uff1f<\/strong><br \/>Jupyter Notebook\u662f\u4e00\u4e2a\u7ecf\u5178\u7684\u7528\u6237\u754c\u9762\uff0c\u9002\u5408\u8fdb\u884c\u7b80\u5355\u7684\u4ea4\u4e92\u5f0f\u7f16\u7a0b\u548c\u6570\u636e\u5206\u6790\uff0c\u800cJupyter Lab\u5219\u662f\u4e00\u4e2a\u66f4\u4e3a\u73b0\u4ee3\u5316\u7684\u73af\u5883\uff0c\u652f\u6301\u591a\u6807\u7b7e\u9875\u548c\u6587\u4ef6\u7ba1\u7406\uff0c\u66f4\u9002\u5408\u8fdb\u884c\u590d\u6742\u9879\u76ee\u7684\u5f00\u53d1\u3002\u5982\u679c\u60a8\u9700\u8981\u5904\u7406\u591a\u4e2a\u6587\u4ef6\u6216\u5e0c\u671b\u66f4\u9ad8\u6548\u5730\u7ba1\u7406\u9879\u76ee\uff0cJupyter Lab\u662f\u4e00\u4e2a\u66f4\u597d\u7684\u9009\u62e9\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Jupyter\u4e2d\u5bfc\u5165\u548c\u4f7f\u7528\u5916\u90e8Python\u6587\u4ef6\uff1f<\/strong><br \/>\u8981\u5728Jupyter\u4e2d\u5bfc\u5165\u5916\u90e8Python\u6587\u4ef6\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528Python\u7684\u6807\u51c6\u5bfc\u5165\u8bed\u53e5\u3002\u5728Notebook\u7684\u4e00\u4e2a\u5355\u5143\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>import<\/code>\u8bed\u53e5\u6765\u5bfc\u5165\u60a8\u9700\u8981\u7684\u6a21\u5757\u6216\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u7684Python\u6587\u4ef6\u540d\u4e3a<code>my_module.py<\/code>\uff0c\u53ef\u4ee5\u901a\u8fc7<code>from my_module import *<\/code>\u6765\u5bfc\u5165\u5176\u4e2d\u7684\u6240\u6709\u51fd\u6570\u548c\u7c7b\u3002\u786e\u4fdd\u60a8\u7684\u6587\u4ef6\u8def\u5f84\u6b63\u786e\uff0c\u6216\u8005\u5c06Python\u6587\u4ef6\u653e\u7f6e\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e2d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Jupyter\u4e2d\u7f16\u8f91Python\u6587\u4ef6\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528\u5185\u7f6e\u6587\u672c\u7f16\u8f91\u5668\u3001\u901a\u8fc7\u7b14\u8bb0\u672c\u7f16\u8f91\u3001\u7ed3\u5408\u5916\u90e8IDE\u4f7f\u7528\u3002 \u5728 [&hellip;]","protected":false},"author":3,"featured_media":1014978,"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\/1014972"}],"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=1014972"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1014972\/revisions"}],"predecessor-version":[{"id":1014980,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1014972\/revisions\/1014980"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1014978"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1014972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1014972"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1014972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}