1

我知道我可以使用这个:

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

在我的 python 解释器中启用 ipython 样式的选项卡完成。

每当我启动 python 时,如何在启动时默认运行它?

4

1 回答 1

3

将其放入文件中.pythonrc(您可以通过环境变量控制该文件的名称PYTHONSTARTUP)。在此处阅读更多信息:

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.

也可以看看:

于 2013-07-12T15:06:21.147 回答