#!/usr/bin/env python # coding: utf-8 # In[18]: ls # In[19]: import nbformat nb = nbformat.read('demo_maxwell-eigenvalues.ipynb', as_version=4) for cell in nb.cells: print(cell.cell_type) print(' %s...' % cell.source.splitlines()[0]) # In[23]: cell3 = nb.cells[3] cell3 # In[24]: cell3.metadata.attributes.classes # In[20]: cell1 = nb.cells[1] # In[21]: new_source = '\n'.join(['```', cell1.source, '````']) new_cell = nbformat.v4.new_markdown_cell(new_source) nb.cells[1] = new_cell new_cell # In[22]: nbformat.write(nb, 'demo_maxwell-eigenvalues.ipynb') # In[ ]: md = # In[11]: nbformat.v4.new_markdown_cell('some markdown') # In[ ]: