您的位置:首页 > 博客中心 > 编程语言 >

Linux 下python 如何设置使用tab键

时间:2022-03-24 19:33

  1. 首先在家目录下创建一个隐藏文件,vi ~/.pythonstartup,内容如下:


# 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


2.设置bash环境变量:

vi /root/.bash_profile

在文件的最后加入一句:

export PYTHONSTARTUP=~/.pythonstartup


3.重启计算机,reboot,然后就可以使用tab键的自动补全功能了。


本文出自 “” 博客,请务必保留此出处

热门排行

今日推荐

热门手游