在ipython控制台中突出显示语法 [英] syntax highlighting in ipython console

查看:113
本文介绍了在ipython控制台中突出显示语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 qtconsole 和终端中使用 ipython

ipython-qtconsole 中,当我输入将pandas导入为pd 时,单词会突出显示语法。

In ipython-qtconsole, when I type import pandas as pd the words have syntax highlighting.

然而,当我输入控制台时,所有文字都是白色

However, when I type in the console, all text is white

是否可以在语法高亮显示python控制台也是?

Is it possible to have syntax highlighting in python console as well?

我的 ipython 版本是;

ipython                    1.2.1
ipython-qtconsole          1.2.1


推荐答案

是的,如果你使用IPython 5.0或更高版本,它会使用 Python提示工具包,它可以在您键入内容时突出显示代码,并支持真实,合理的多行版本。

Yes, if you use IPython 5.0 or above, It makes uses of Python Prompt Toolkit which does highlight code as you type, as well as support real, and sane multi-line edition.

要升级使用:

pip install  ipython --upgrade

这是基于o n Jonathan Slenders关于 ptpython 的工作:

This is based on the work of Jonathan Slenders on ptpython:

python -m pip install ptpython

提供2命令: ptpython ptipython 这应该在终端中突出显示语法。 ptipython 是一个概念证明,因此可能会错过IPython的某些功能,但会进一步推动界面。

which provide 2 commands: ptpython and ptipython which should syntax highlight in your terminal. ptipython is a proof of concept so will likely miss some functionality of IPython, but push the interface a bit further.

请注意,jupyter-console(可以作为内核连接到IPython)也会在您键入时使用提示工具包和突出显示代码。

Note that jupyter-console, which can connect to IPython as a kernel will also make use of prompt toolkit and highlight code as you type.

这篇关于在ipython控制台中突出显示语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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