zwi*_*uta 4 code-snippets jupyter-notebook jupyter-contrib-nbextensions
我尝试按照扩展的自述文件中给出的说明进行操作。我使用 Windows 并打开我的笔记本,我使用存储在目录中的 jupyter-notebook.exe
..\Anaconda3\脚本
在 Anaconda3 目录中,我转到子目录
Anaconda3\Lib\site-packages\jupyter_contrib_nbextensions\nbextensions\snippets
并更改文件“snippets.json”的代码
{
"snippets" : [
{
"name" : "example",
"code" : [
"# This is an example snippet!",
"# To create your own, add a new snippet block to the",
"# snippets.json file in your jupyter data directory under nbextensions:",
"# $(jupyter --data-dir)/nbextensions/snippets/snippets.json",
"import this"
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
到
{
"snippets" : [
{
"name" : "example",
"code" : [
"# This is a test if something changed",
]
]
}
Run Code Online (Sandbox Code Playgroud)
然后我重新启动笔记本并插入示例片段。但我的更改没有被采纳,我仍然把原来的例子剪掉了。
我做错了什么?
小智 7
如果您使用 Anaconda,则不一定需要搜索目录。“Nbextensions”选项卡中嵌入了一个模板。
看看我的一个片段:
{
"name" : "My favorites",
"sub-menu" : [
{
"name" : "import packages",
"snippet" : ["# import various packages"
"import os"
"import scipy"
"import pandas as pd"
"import numpy as np"
"import seaborn as sns"
"import matplotlib.pyplot as plt"
"%matplotlib inline"
"# plot settings"
"from pandas.plotting import register_matplotlib_converters"
"register_matplotlib_converters()"
"plt.rcParams['agg.path.chunksize'] = 10000"]
},
{
"name" : "TeX can be written in menu labels $\\alpha_W e\\int_0 \\mu \\epsilon$",
"snippet" : ["another_new_command(2.78)"]
}
]
}
Run Code Online (Sandbox Code Playgroud)
另外,请注意引号和逗号。可以在此处找到更多帮助。
| 归档时间: |
|
| 查看次数: |
6067 次 |
| 最近记录: |