这篇文章将为大家详细讲解有关python中自动补全tab是示例分析,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
1、在python中运行命令sys.path查看python路径
>>> import sys
>>> import tab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tab
>>> sys.path
['', '/usr/lib64/python26.zip', '/usr/lib64/python2.6', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/lib64/python2.6/site-packages', '/usr/lib64/python2.6/site-packages/gst-0.10', '/usr/lib64/python2.6/site-packages/gtk-2.0', '/usr/lib64/python2.6/site-packages/webkit-1.0', '/usr/lib/python2.6/site-packages', '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info']
2、创建 tab.py 文件
[root@mysql2 ~]# cd /usr/lib/python2.6/site-packages
[root@mysql2 site-packages]# cat tab.py
#!/usr/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
3、 导入 tab 模块
>>> import tab
>>> f
file( filter( finally float( for format( from frozenset(
关于python中自动补全tab是示例分析就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
原创文章,作者:3628473679,如若转载,请注明出处:https://blog.ytso.com/200198.html