python3.6 添加tab键功能

版权声明:本文为博主原创文章,欢迎转载,但请注明原文出处。 https://blog.csdn.net/GiveMeFive_Y/article/details/79971054

1. 编辑文件

  # vim /usr/lib/python3.6/site-packages/tab.py 

  1import sys,readline,rlcompleter,atexit,os
  2 
  3 readline.parse_and_bind('tab: complete')
  4 histfile = os.path.join(os.environ['HOME'], '.pythonhistory')
  5 try:
  6     readline.read_history_file(histfile)
  7 except IOError:
  8     pass
  9     atexit.register(readline.write_history_file, histfile)
 10 del os, histfile, readline, rlcompleter

2. 设置环境变量

export PYTHONSTARTUP=/usr/lib/python3.6/site-packages/tab.py

写入~/.bash_profile文件保存退出然后
source ~/.bash_profile (让该配置文件生效)

3. 测试

(python36) [root@aliyun ~]# python 
Python 3.6.4 (default, Apr 17 2018, 09:31:58) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.sys  # 敲tab键
os.sys            os.sysconf(       os.sysconf_names  os.system(        
>>> os.sys

猜你喜欢

转载自blog.csdn.net/GiveMeFive_Y/article/details/79971054
今日推荐