Python 官方文档:入门教程 => 点击学习
1.准备一个脚本如下:#!/usr/bin/python # Python tab file import sys import readline import rlcompleter import atexit import
1.准备一个脚本如下:
#!/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
2.查看Python默认的模块存放地址
>>> import sys
>>> sys.path
['', '/usr/local/python2.7/lib/python2.7/site-packages/distribute-0.6.49-py2.7.egg', '/usr/local/python2.7/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg', '/usr/local/python2.7/lib/python27.zip', '/usr/local/python2.7/lib/python2.7', '/usr/local/python2.7/lib/python2.7/plat-linux2', '/usr/local/python2.7/lib/python2.7/lib-tk', '/usr/local/python2.7/lib/python2.7/lib-old', '/usr/local/python2.7/lib/python2.7/lib-dynload', '/usr/local/python2.7/lib/python2.7/site-packages', '/usr/local/python2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
3. 创建该脚本到默认模块存放路径
vi /usr/local/python2.7/lib/python2.7/tab.py
4导入tab模块,验证.
>>> import tab
>>> sys.
sys.__class__( sys.api_version sys.hexversion
sys.__delattr__( sys.argv sys.long_info
--结束END--
本文标题: python之tab补全模块
本文链接: https://lsjlt.com/news/189394.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0