Python_lab-如何通过colab来转换把ipynb文件转化为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))

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

[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')

结束

猜你喜欢

转载自blog.csdn.net/Jiana_Feng/article/details/109977195