微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。