码迷,mamicode.com
首页 > 编程语言 > 详细

python tab补全

时间:2018-06-29 19:23:41      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:lib64   let   format   IV   adl   type   atexit   一段   补全   

看视频发现讲课的老师python可以tab补全,网上找了一段代码
如下:

[root@node01 data]#vi tab.py

 1 #!/usr/bin/env python
 2 # python startup file 
 3 import sys
 4 import readline
 5 import rlcompleter
 6 import atexit
 7 import os
 8 # tab completion 
 9 readline.parse_and_bind(tab: complete)
10 # history file 
11 histfile = os.path.join(os.environ[HOME], .pythonhistory)
12 try:
13     readline.read_history_file(histfile)
14 except IOError:
15     pass
16 atexit.register(readline.write_history_file, histfile)
17 del os, histfile, readline, rlcompleter

拷贝到python命令路径

[root@node01 data]#cp tab.py /usr/lib64/python2.6

导入

[root@node01 data]# python
Python 2.6.6 (r266:84292, Aug 18 2016, 15:13:37) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tab
>>> import sys
>>> sys.p
sys.path                 sys.platform             sys.ps2
sys.path_hooks           sys.prefix               sys.py3kwarning
sys.path_importer_cache  sys.ps1  

技术分享图片

 

python tab补全

标签:lib64   let   format   IV   adl   type   atexit   一段   补全   

原文地址:https://www.cnblogs.com/nul1/p/9244863.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!