如何在Jupyter笔记本中包装代码/文本 [英] How to wrap code/text in Jupyter notebooks

查看:135
本文介绍了如何在Jupyter笔记本中包装代码/文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jupyter-notebooks进行python编码.有没有办法将文本/代码包装在jupyter笔记本代码单元中?

I am using jupyter-notebooks for python coding. Is there a way to wrap text/code in a jupyter notebook code cell?

下面提供的图片.

自动换行"表示如何用MS-word换行"

By wrap text means "how text is wrapped in MS-word"

推荐答案

通过jupyter --config-dir查找您的配置目录(我的是~/.jupyter).然后编辑或创建nbconfig/notebook.json以添加以下内容:

Find your configuration directory via jupyter --config-dir (mine is ~/.jupyter). Then edit or create nbconfig/notebook.json to add the following:

{
  "MarkdownCell": {
    "cm_config": {
      "lineWrapping": true
    }
  },
  "CodeCell": {
    "cm_config": {
      "lineWrapping": true
    }
  }
}

(如果其中还有其他内容,请确保您具有有效的JSON,并且在}之后没有尾随逗号.)

(If you have something else in it, ensure you have valid JSON with no trailing commas after }s.)

重新启动Jupyter并重新加载笔记本.

Restart Jupyter and reload your notebook.

来源: https://github.com/jupyter/notebook/issues/106

这篇关于如何在Jupyter笔记本中包装代码/文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆