首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Python 中的tab补全

Python 中的tab补全

作者头像
py3study
发布2020-01-10 12:37:24
6740
发布2020-01-10 12:37:24
举报
文章被收录于专栏:python3python3

用Python时候没有TAB补全,挺痛苦的,以下是添加方法

1.准备一个Python脚本 cat > tab.py <<EOF #!/usr/local/bin/python # python tab 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 EOF 2.查看Python默认的模块存放位置 [root@victor python2.7]# python Python 2.7.6 (default, Sep 17 2017, 04:41:33) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7', '/usr/local/lib/python2.7/plat-linux2', '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', '/usr/local/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages'] 3.拷贝到目录下 cp tab.py /usr/local/lib/python2.7 4.现在可以用了 [root@victor python]# cp tab.py /usr/local/lib/python2.7 [root@victor python]# python Python 2.7.6 (default, Sep 17 2017, 04:41:33) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import tab >>> import sys >>> sys. sys.__class__(              sys.__sizeof__(             sys.displayhook(            sys.getprofile(             sys.ps1 sys.__delattr__(            sys.__stderr__              sys.dont_write_bytecode     sys.getrecursionlimit(      sys.ps2 sys.__dict__                sys.__stdin__               sys.exc_clear(              sys.getrefcount(            sys.py3kwarning sys.__displayhook__(        sys.__stdout__              sys.exc_info(               sys.getsizeof(              sys.setcheckinterval( sys.__doc__                 sys.__str__(                sys.exc_type                sys.gettrace(               sys.setdlopenflags( sys.__excepthook__(         sys.__subclasshook__(       sys.excepthook(             sys.hexversion              sys.setprofile( sys.__format__(             sys._clear_type_cache(      sys.exec_prefix             sys.long_info               sys.setrecursionlimit( sys.__getattribute__(       sys._current_frames(        sys.executable              sys.maxint                  sys.settrace( sys.__hash__(               sys._getframe(              sys.exit(                   sys.maxsize                 sys.stderr sys.__init__(               sys._mercurial              sys.exitfunc(               sys.maxunicode              sys.stdin sys.__name__                sys.api_version             sys.flags                   sys.meta_path               sys.stdout sys.__new__(                sys.argv                    sys.float_info              sys.modules                 sys.subversion sys.__package__             sys.builtin_module_names    sys.float_repr_style        sys.path                    sys.version sys.__reduce__(             sys.byteorder               sys.getcheckinterval(       sys.path_hooks              sys.version_info sys.__reduce_ex__(          sys.call_tracing(           sys.getdefaultencoding(     sys.path_importer_cache     sys.warnoptions sys.__repr__(               sys.callstats(              sys.getdlopenflags(         sys.platform                 sys.__setattr__(            sys.copyright               sys.getfilesystemencoding(  sys.prefix         

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-08-20 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档