让 python 命令行也可以自动补全

WBOY
Release: 2016-06-06 11:21:03
Original
1153 people have browsed it

许多人都知道 iPython 有很好的自动补全能力,但是就未必知道 python 也同样可以 Tab 键补全,
您可以在启动 python 后,执行下

代码如下:


import readline, rlcompleter; readline.parse_and_bind("tab: complete")

这就可以按 Tab 键补全了。

python 自启动
如果您嫌每次都要键入这东西麻烦的话,可以把上边这行写到 ~/.pythonstartup.py ,
再 ~/.bashrc 里加一个环境变量

export PYTHONSTARTUP=~/.pythonstartup.py这就会每次启动 python 都先执行了

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template