像python cons中的ipython那样的默认制表符完成

2024-04-20 05:16:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我知道我可以用这个:

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

在python解释器中启用ipython样式的制表符完成。你知道吗

无论何时启动python,我都可以在启动时默认运行它吗?你知道吗


Tags: andimportreadlineparsebindipython样式tab
1条回答
网友
1楼 · 发布于 2024-04-20 05:16:10

将其放入文件.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.

另请参见:

相关问题 更多 >