import json
def convert_ipynb_to_py(ipynb_file, py_file):
with open(ipynb_file, 'r',encoding='utf-8') as f:
notebook = json.load(f)
with open(py_file, 'w',encoding='utf-8') as f:
for cell in notebook['cells']:
if cell['cell_type'] == 'code':
f.write(''.join(cell['source']) + '\n\n')
convert_ipynb_to_py('原文件名.ipynb', '生成文件名.py')
09-19
5265

08-06
1412

10-22
2万+

05-06
8223
