Python 官方文档:入门教程 => 点击学习
python装完是不能用tab来补全的,我们需要将脚本放到Python指定的目录下,可以使用sys.path来查看一下目录>>> import sys>>> sys.path['', '/usr/loca
python装完是不能用tab来补全的,我们需要将脚本放到Python指定的目录下,可以使用sys.path来查看一下目录
>>> import sys
>>> sys.path
['', '/usr/local/python2.7.10/lib/python27.zip', '/usr/local/python2.7.10/lib/python2.7', '/usr/local/python2.7.10/lib/python2.7/plat-linux2', '/usr/local/python2.7.10/lib/python2.7/lib-tk', '/usr/local/python2.7.10/lib/python2.7/lib-old', '/usr/local/python2.7.10/lib/python2.7/lib-dynload', '/usr/local/python2.7.10/lib/python2.7/site-packages']
一般我们会将这一类代码放在/usr/local/xxxxx/lib/python2.7/dist-packages目录下
[root@python ~]# cd /usr/local/python2.7.10/lib/python2.7/site-packages
[root@python site-packages]# vi 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
[root@python site-packages]# python
Python 2.7.10 (default, Dec 4 2015, 23:46:26)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more infORMation.
>>> import tab
>>> import sys
>>> sys.
sys.__class__( sys.__reduce_ex__( sys.argv sys.exit( sys.hexversion sys.py3kwarning
sys.__delattr__( sys.__repr__( sys.builtin_module_names sys.exitfunc( sys.long_info sys.setcheckinterval(
sys.__dict__ sys.__setattr__( sys.byteorder sys.flags sys.maxint sys.setdlopenflags(
sys.__displayhook__( sys.__sizeof__( sys.call_tracing( sys.float_info sys.maxsize sys.setprofile(
--结束END--
本文标题: Python tab键补全
本文链接: https://lsjlt.com/news/184846.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