python - 像 python 控制台中的 ipython 一样默认制表符补全

标签 python

我知道我可以使用这个:

import rlcompleter, readline
readline.parse_and_bind('tab: complete')

在我的 python 解释器中启用 ipython 风格的制表符补全。

如何在每次启动 python 时默认在启动时运行它?

最佳答案

将其放入文件.pythonrc(您可以通过环境变量PYTHONSTARTUP控制该文件的名称)。了解更多关于 here :

PYTHONSTARTUP
If this is the name of a readable file, the Python commands 
in that file are executed before the first prompt is displayed
in interactive mode. The file is executed in the same namespace
where interactive commands are executed so that objects defined
or imported in it can be used without qualification in the interactive
session. You can also change the prompts sys.ps1 and sys.ps2 in this file.

另请参阅:

关于python - 像 python 控制台中的 ipython 一样默认制表符补全,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17617992/

相关文章:

python - Python 中的排名是什么?

Python Pandas - 将日期列读取为字符串

python - Django 模板翻译中的复杂引号转义

python - Keras - RTX 2080 ti 训练比仅 CPU 和 GTX 1070 慢?

Python 日志记录 : Inherit contextual information

python - Pandas:在单独的列中显示嵌套字典值

python - Python 中的 TextCalendar 导入错误

python - 在python中复制选定的文件

python - Pandas, Python : rotate some (31-day) columns of a dataframe and match them to the existing (year, 月)行(NOAA 数据)

python - 在 Python 中实现深度优先树迭代器