当前位置:   article > 正文

Python_lab-如何通过colab来转换把ipynb文件转化为html格式_google colab jupyter nbconvert -to html

google colab jupyter nbconvert -to html

由于colab上没有直接转换成html文档的选,所以需要自己设置转换的要求。
下面是转换的步骤

1. 下载ipynb文件到本地电脑上
2. 再upload ipynb文件到colab上,操作如下
from google.colab import files
uploaded = files.upload()
for filename in uploaded.keys():
  print('Your notebook file "{name}" has been uploaded to the colab machine instance'.format(name=filename))
  • 1
  • 2
  • 3
  • 4

output:
5245_HW4_jf3283.ipynb(n/a) - 104620 bytes, last modified: 11/23/2020 - 100% done
Saving 5245_HW4_jf3283.ipynb to 5245_HW4_jf3283.ipynb
Your notebook file “5245_HW4_jf3283.ipynb” has been uploaded to the colab machine instance

运行上面的code将会 从本地电脑选择文件,然后上传到colab

3. 转换为html文件

直接运行这行代码

!jupyter nbconvert --to html *.ipynb
  • 1

[NbConvertApp] Converting notebook 5245_HW4_jf3283.ipynb to html
[NbConvertApp] Writing 399771 bytes to 5245_HW4_jf3283.html

4. 把转换好的html文件直接下载到本地
files.download(filename[:-5]+'html')
  • 1

结束

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/212089
推荐阅读
相关标签
  

闽ICP备14008679号