如何将 Colab 笔记本导出为 pdf 文件

发布于 2025-01-18 09:15:56 字数 156 浏览 0 评论 0原文

这是我第一次在这个论坛上问一个问题,因此,任何提示或建议都非常感谢!

至于问题本身,我已经看到了有关如何将Colab笔记本电脑导出为PDF的许多讨论,但是我想更具体地询问是否有任何方法可以保留执行代码的输出(例如:我希望用熊猫的数据框制成的桌子在笔记本上打印出来,而不是一堆字符串)。

this is my first time asking a question on this forum, so, any tip or suggestion is highly appreciated!

As for the question itself, I have already seen many discussions on how to export a Colab notebook as a pdf, however I would like to ask more specifically if there is any way of doing it that can preserve the output of executed code (e.g.: I would like tables made from dataframe in pandas to be exported as they were printed on the notebook and not like a bunch of strings).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小猫一只 2025-01-25 09:15:56

我认为更简单的方法是您可以使用浏览器打印功能。
对于大多数浏览器,其快捷方式应该是 ctrl + p,

更难的方法是您可以将 ipynb 文件下载到您的计算机上,然后使用 jupyter 笔记本来执行此

操作工作中,您应该安装 notebook-as-pdf pip 包,然后您需要在命令行或终端中使用此命令

pyppeteer-install

,之后您就可以使用 jupyter Notebook 打开您的 ipynb你应该找到文件菜单的“下载为”部分中的“PDF via HTML(pdf)”选项,

换句话说,它应该在这里:

file > download as > PDF via HTML(pdf)

如果您想了解有关此用途的更多详细信息这个这个

I think the easier method is you can use browser print functionality.
for most browser it's shortcut should be ctrl + p

and the the harder method is that you can download ipynb file to your machine and then use jupyter notebook to do this

for this to work you should install notebook-as-pdf pip package and then you need to use this command in your command-line or terminal

pyppeteer-install

after that you are all set, so now you can open your ipynb with jupyter notebook and you should find "PDF via HTML(pdf)" option in "download as" section of file menu

in other word it should be here:

file > download as > PDF via HTML(pdf)

if you want more details on this use this and this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文