centos中配置python的tab键自动补全功能

前端之家收集整理的这篇文章主要介绍了centos中配置python的tab键自动补全功能前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

centos中配置python的tab键自动补全功能

一、首先打开python,观察python的安装路径

[root@localhost ~]# python

Python 3.6.2 (default,Aug 14 2017,22:12:34)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux

Type "help","copyright","credits" or "license" for more information.

>>> import sys

>>> sys.path

['','/usr/local/lib/python36.zip','/usr/local/lib/python3.6','/usr/local/lib/python3.6/lib-dynload','/root/.local/lib/python3.6/site-packages','/usr/local/lib/python3.6/site-packages']

>>>


二、退出python、进入python目录

[root@localhost ~]# cd /usr/local/lib/python3.6/


三、新建tab.py文件,并且输入配置内容

[root@localhost python3.6]# vim tab.py

输入:

#!/usr/bin/env python

# 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:

【更新地址】http://doublelinux.blog.51cto.com/12300166/1966544

pass

atexit.register(readline.write_history_file,histfile)

del os,histfile,readline,rlcompleter


四、验证

[root@localhost python3.6]# python

Python 3.6.2 (default,"credits" or "license" for more information.

>>> a

abs( all( and any( as ascii( assert

>>> b

bin( bool( break bytearray( bytes(

>>> c

callable( chr( class classmethod( compile( complex( continue

>>>

wKioL1nAdo2ghRGPAABDE5pm1FA125.png

【更新地址】http://doublelinux.blog.51cto.com/12300166/1966544

猜你在找的CentOS相关文章