input_file = 'IUM_02.ipynb' output_file = 'IUM_02.py' import nbformat from nbconvert import PythonExporter with open(input_file, 'r', encoding='utf-8') as f: nb = nbformat.read(f, as_version=4) exporter = PythonExporter() source, meta = exporter.from_notebook_node(nb) with open(output_file, 'w', encoding='utf-8') as f: f.write(source)