Python tab键补全
Python装完是不能用tab来补全的,我们需要将脚本放到python指定的目录下,可以使用sys.path来查看一下目录
>>> import sys
>>> sys.path
['', '/usr/local/python2.7.10/lib/python27.zip', '/usr/local/python2.7.10/lib/python2.7', '/usr/local/python2.7.10/lib/python2.7/plat-linux2', '/usr/local/python2.7.10/lib/python2.7/lib-tk', '/usr/local/python2.7.10/lib/python2.7/lib-old', '/usr/local/python2.7.10/lib/python2.7/lib-dynload', '/usr/local/python2.7.10/lib/python2.7/site-packages']
一般我们会将这一类代码放在/usr/local/xxxxx/lib/python2.7/dist-packages目录下
[root@python ~]# cd /usr/local/python2.7.10/lib/python2.7/site-packages
[root@python site-packages]# vi 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:
pass
atexit.register(readline.write_history_file, histfile)
del os, histfile, readline, rlcompleter
[root@python site-packages]# python
Python 2.7.10 (default, Dec 4 2015, 23:46:26)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tab
>>> import sys
>>> sys.
sys.__class__( sys.__reduce_ex__( sys.argv sys.exit( sys.hexversion sys.py3kwarning
sys.__delattr__( sys.__repr__( sys.builtin_module_names sys.exitfunc( sys.long_info sys.setcheckinterval(
sys.__dict__ sys.__setattr__( sys.byteorder sys.flags sys.maxint sys.setdlopenflags(
sys.__displayhook__( sys.__sizeof__( sys.call_tracing( sys.float_info sys.maxsize sys.setprofile(
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341