在写Python语言过程中会经常用到各种模块,不知道具体用模块下那个方法时要去查资料,严重影响工作效率。python也可以和linux一样有tab键自动补全功能。希望对大家学习Python语言有所帮助。
步骤如下:
1、linux 系统下编写tab的自动补全脚本,名为tab.py。
[root@hao25 ~]# vim tab.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'], '.pythonhisto
ry')
try:
readline.read_history_file(histfile)
except IOError:
pass
atexit.register(readline.write_history_file, histfile)
del os, histfile, readline, rlcompleter
2,进入python 环境下查看python 模块路径。
>>> import sys
>>> sys.path
['', '/usr/lib64/python26.zip', '/usr/l