jgfhrt 发表于 2015-10-8 08:13:18

python tab键自动补齐命令

操作步骤:
      一:安装readline
                yum -y install readline
      二:vim ~/.pythonstartup.py

# python startup file
import sys
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


      三:写入环境变量里
                vim ~/.bash_profile
                        export PYTHONSTARTUP=~/.pythonstartup.py

      四:载入.bash_profile
                        source ~/.bash_profile

页: [1]
查看完整版本: python tab键自动补齐命令