前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >python tab键补齐

python tab键补齐

作者头像
py3study
发布2020-01-13 20:24:55
1.2K0
发布2020-01-13 20:24:55
举报
文章被收录于专栏:python3python3

在mac上测试

代码语言:javascript
复制
ipython
In [4]: import sys 
In [5]: sys.path
Out[5]: 
['',
 '/usr/local/bin',
 '/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg',
 '/Library/Python/2.7/site-packages/mysql-0.0.1-py2.7.egg',
 '/Library/Python/2.7/site-packages/ipython-3.2.1-py2.7.egg',
 '/Library/Python/2.7/site-packages/gnureadline-6.3.3-py2.7-macosx-10.8-intel.egg',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
 '/Library/Python/2.7/site-packages',
 '/Library/Python/2.7/site-packages/ipython-3.2.1-py2.7.egg/IPython/extensions',
 '/private/var/root/.ipython']

代码有了,我们还需要将脚本放到python指定的目录下,可以使用sys.path来查看一下

(linux服务器):一般我们会将这一类代码放在/usr/local/lib/python2.7/dist-packages目录下

(MAC存放在这个目录下)/Library/Python/2.7/site-packages

代码语言:javascript
复制
admindeMacBook-Air-62:site-packages admin$ 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:
    pass
atexit.register(readline.write_history_file, histfile)
del os, histfile, readline, rlcompleter

代码中就可以import tab了

代码语言:javascript
复制
In [11]: import tab
In [12]: sys.
sys.__class__(              sys.__setattr__(            sys.displayhook(            sys.getrecursionlimit(      sys.prefix
sys.__delattr__(            sys.__sizeof__(             sys.dont_write_bytecode     sys.getrefcount(            sys.ps1
sys.__dict__                sys.__stderr__              sys.exc_clear(              sys.getsizeof(              sys.ps2
sys.__displayhook__(        sys.__stdin__               sys.exc_info(               sys.gettrace(               sys.ps3
sys.__doc__                 sys.__stdout__              sys.exc_type                sys.hexversion              sys.py3kwarning
sys.__egginsert             sys.__str__(                sys.excepthook(             sys.last_traceback          sys.setcheckinterval(
sys.__excepthook__(         sys.__subclasshook__(       sys.exec_prefix             sys.last_type(              sys.setdlopenflags(
sys.__format__(             sys._clear_type_cache(      sys.executable              sys.last_value              sys.setprofile(
sys.__getattribute__(       sys._current_frames(        sys.exit(                   sys.long_info               sys.setrecursionlimit(
sys.__hash__(               sys._getframe(              sys.exitfunc(               sys.maxint                  sys.settrace(
sys.__init__(               sys._mercurial              sys.flags                   sys.maxsize                 sys.stderr
sys.__name__                sys.api_version             sys.float_info              sys.maxunicode              sys.stdin
sys.__new__(                sys.argv                    sys.float_repr_style        sys.meta_path               sys.stdout
sys.__package__             sys.builtin_module_names    sys.getcheckinterval(       sys.modules                 sys.subversion
sys.__plen                  sys.byteorder               sys.getdefaultencoding(     sys.path                    sys.version
sys.__reduce__(             sys.call_tracing(           sys.getdlopenflags(         sys.path_hooks              sys.version_info
sys.__reduce_ex__(          sys.callstats(              sys.getfilesystemencoding(  sys.path_importer_cache     sys.warnoptions
sys.__repr__(               sys.copyright               sys.getprofile(             sys.platform 

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

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

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

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

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