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

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

问题描述

我正在使用 jupyter-notebooks 进行 Python 编码.有没有办法在 jupyter notebook 代码单元格中包装文本/代码?

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,} s 后没有尾随逗号.)

(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天全站免登陆