我正在从我的笔记本jupyter-nbconvert --to script mynb.ipynb
中获取一个。.py
这给了我笔记本中的所有内容。我想知道是否可以将 nbconvert 设置为.py
仅将标记为initialization
笔记本中的单元格保存在脚本中。我想我需要为此制作一个模板,但是如果nbconvert对我来说读起来不是很好,尤其是在这种情况下,自定义。
这就是 ipynb 的样子。可以"init_cell": true
在定制中使用吗?
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2018-07-06T02:39:41.586987Z",
"start_time": "2018-07-06T02:39:41.412779Z"
},
"collapsed": true,
"tags": [
"ATaggedCell"
]
},
"outputs": [],
"source": [
"# this is tagged, but is not an initialization cell\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"init_cell": true
},
"outputs": [],
"source": [
"# this is not tagged, but is an initialization cell\n",
"import pandas as pd"
]
}
],