本文整理匯總了Python中nbconvert.exporters.HTMLExporter.from_file方法的典型用法代碼示例。如果您正苦於以下問題:Python HTMLExporter.from_file方法的具體用法?Python HTMLExporter.from_file怎麽用?Python HTMLExporter.from_file使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nbconvert.exporters.HTMLExporter
的用法示例。
在下文中一共展示了HTMLExporter.from_file方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: render_ipynb
# 需要導入模塊: from nbconvert.exporters import HTMLExporter [as 別名]
# 或者: from nbconvert.exporters.HTMLExporter import from_file [as 別名]
def render_ipynb(full_path):
"""
Render a given ipynb file
"""
exporter = HTMLExporter()
with open(full_path, encoding='utf-8') as file_handle:
html, res = exporter.from_file(file_handle)
return Response(html, mimetype='text/html')
示例2: generate_exercises
# 需要導入模塊: from nbconvert.exporters import HTMLExporter [as 別名]
# 或者: from nbconvert.exporters.HTMLExporter import from_file [as 別名]
def generate_exercises():
p = Path(*EXERCISES_DIR)
exporter = HTMLExporter()
exporter.register_preprocessor(ClearOutputPreprocessor(), enabled=True)
for exercise in p.iterdir():
if exercise.suffix == '.ipynb':
html, _ = exporter.from_file(exercise.open())
with open(exercise.with_suffix('.html').name, 'w') as f:
f.write(html)
示例3: reload
# 需要導入模塊: from nbconvert.exporters import HTMLExporter [as 別名]
# 或者: from nbconvert.exporters.HTMLExporter import from_file [as 別名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
from nbconvert.exporters import HTMLExporter
from traitlets.config import Config
config = Config({
"HTMLExporter": {"template_file": "basic"},
'NbConvertBase': {
'display_data_priority': [
'text/html',
'text/markdown',
'application/pdf',
'image/svg+xml',
'text/latex',
'image/png',
'image/jpeg',
'text/plain',
]
}
})
ex = HTMLExporter(config=config)
html, extra = ex.from_file(sys.stdin)
sys.stdout.write(html)