zoukankan      html  css  js  c++  java
  • Python的自动补全

    1、编辑文件 tab.py
     
     1 vi tab.py
     2  
     3 #!/usr/bin/env python
     4 # python startup file
     5 import sys
     6 import readline
     7 import rlcompleter
     8 import atexit
     9 import os
    10 # tab completion
    11 readline.parse_and_bind('tab: complete')
    12 # history file
    13 histfile = os.path.join(os.environ['HOME'], '.pythonhistory')
    14 try:
    15     readline.read_history_file(histfile)
    16 except IOError:
    17     pass
    18 atexit.register(readline.write_history_file, histfile)
    19 del os, histfile, readline, rlcompleter
     
    2、确认 第三方脚本或模块存放路径
     
    1 [root@sun ~]# python
    2 Python 2.7.12 (default, Aug 23 2016, 16:39:04)
    3 [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
    4 Type "help", "copyright", "credits" or "license" for more information.
    5 >>> import sys
    6 >>> sys.path
    7 ['', '/usr/local/python27/lib/python27.zip', '/usr/local/python27/lib/python2.7', '/usr/local/python27/lib/python2.7/plat-linux2', '/usr/local/python27/lib/python2.7/lib-tk', '/usr/local/python27/lib/python2.7/lib-old', '/usr/local/python27/lib/python2.7/lib-dynload', '/usr/local/python27/lib/python2.7/site-packages']
    8 >>>
    3、将编辑好的 tab.py 脚本放到  /usr/local/python27/lib/python2.7/site-packages 目录一份
     
    1 [root@sun ~]# cp tab.py /usr/local/python27/lib/python2.7/site-packages/
     
    4、验证结果
     
     1 [root@sun ~]# python
     2 Python 2.7.12 (default, Aug 23 2016, 16:39:04)
     3 [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
     4 Type "help", "copyright", "credits" or "license" for more information.
     5 >>> import tab
     6 >>> h
     7 hasattr(  hash(     help(     hex(     
     8 >>> h
     9 >>> s
    10 set(           slice(         staticmethod(  sum(           
    11 setattr(       sorted(        str(           super(
     
     
  • 相关阅读:
    iOS重签名及问题总结
    安装class-dump
    UISearchController 很坑
    hashmap 之哈希冲突
    wait()与sleep()的区别
    docker之es+es-head+kibana+ik分词器安装
    MySQL很有用的命令
    分布式事务执行逻辑
    索引 创建原则
    合理使用存储引擎
  • 原文地址:https://www.cnblogs.com/www1707/p/5821208.html
Copyright © 2011-2022 走看看