python命令行tab补全_python命令行下按tab建补全的方法
此方法只在centos6上測(cè)試通過(guò),其它系統(tǒng)木有測(cè)試
1、在用戶家目錄下創(chuàng)建一個(gè)名字叫?.pythonstartup 的隱藏文件,寫(xiě)入如下內(nèi)容:
# python startup file
import readline
import rlcompleter
import atexit
import os
# tab completion
readline.parse_and_bind('tab: complete')
# history file
histfile = os.path.join(os.environ['HOME'], '.pythonhistory')
try:
readline.read_history_file(histfile)
except IOError:
pass
atexit.register(readline.write_history_file, histfile)
del os, histfile, readline, rlcompleter
注意,上面?zhèn)€的格式不要寫(xiě)錯(cuò)了!!!
2、導(dǎo)入一個(gè)環(huán)境變量到系統(tǒng)
我這里只在linux的家目錄下導(dǎo)入一個(gè)PYTHONSTARTUP環(huán)境變量,方法如下:
# echo "export PYTHONSTARTUP=~/.pythonstartup" >> ~/.bashrc
總結(jié)
以上是生活随笔為你收集整理的python命令行tab补全_python命令行下按tab建补全的方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: python传中文参数_解决Python
- 下一篇: java文本框背景_用Java编写小程序