首页 > 代码库 > python tab键补齐
python tab键补齐
在mac上测试
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
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了
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.
本文出自 “梅花香自苦寒来!” 博客,请务必保留此出处http://daixuan.blog.51cto.com/5426657/1934112
python tab键补齐
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。