convert jupyter notebook to a python file
This commit is contained in:
parent
0f49dba47e
commit
da69e7e24a
11
convert.py
Normal file
11
convert.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import nbformat
|
||||||
|
from nbconvert import PythonExporter
|
||||||
|
|
||||||
|
with open('main.ipynb', "r", encoding="utf-8") as f:
|
||||||
|
notebook = nbformat.read(f, as_version = 4)
|
||||||
|
|
||||||
|
exporter = PythonExporter()
|
||||||
|
python_code, _ = exporter.from_notebook_node(notebook)
|
||||||
|
|
||||||
|
with open('main.py', "w", encoding="utf-8") as f:
|
||||||
|
f.write(python_code)
|
Loading…
Reference in New Issue
Block a user