Python tab补全命令

#!/usr/bin/env python
#-*-UTF-8-*-
#!/usr/bin/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
时间: 2024-08-22 22:34:59

Python tab补全命令的相关文章

mac pro python tab补全脚本

之前习惯在win或者linux 下写python小脚本,经常先把tab补全环境配置好,到了mac下发现之前在linux下的tab.py脚本都不适用,自己参考了mac python tab补全的官网略微修改了下,发现蛮好用的. mac pro 下配置的是全局的,不需要再终端输入:python  =>import tab.py  ,这样完全没必要. 具体的mac tab 补全脚本参考下面: $ cat ~/.pythonstartup #-*- coding:utf-8 -*- import os,

linux下Python tab补全功能代码

1.在学习linux的童鞋都用惯了tab补全功能,从而在学习Python的同时,一是为了方便,二是可以看到更多的关于Python命令下的知识. 2.配置步骤: (1) 在linux下键入这样的代码: vim tab.py #!/usr/bin/python # python tab file import sys import readline import rlcompleter import atexit import os #tab completion readline.parse_an

python tab补全

让python的交互解释器支持tab补全.提示功能 方法1: 一.执行python脚本 1.创建一个python脚本,以.py结尾: 脚本如下: import sys import readline import rlcompleter import atexit import os readline.parse_and_bind('tab:complete') histfile =os.path.join(os.environ['HOME'], '.pythonhistory') try: r

Red Hat 7下python tab补全

最近学习python,总结一下如何添加shell脚本,达到(对象.)时,tab按2下调用所有方法的出现. 1.首先在目录:/usr/lib64/python2.7/site-packages下面建立vim tab.py文件. 2.tab.py文件下面的内容: #!/usr/bin/python import os import readline import rlcompleter import atexit import os # tab completion readline.parse_a

Mac或者linux系统自动加载python tab补全功能

因为mac OS属于类unix系统,所以基本和linux系统使用相差不大,只是用户登陆时自动执行环境变量文件的区别 mac系统: ShanedeMBP:login_api shane$ vi ~/.bash_profile linux系统: [[email protected] ~]# ls -a .bash* .bash_history .bash_logout .bash_profile .bashrc linux中有bash_profile,bashrc,以下是区别: /etc/profi

Python tab 补全

1. 先准备一个tab.py的脚本 shell> cat tab.py 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 #!/usr/bin/python # python tab file   import sys import readline import rlcompleter import atexit import os # tab completion readline.parse_and_bind('tab: complete')

unbtun python tab补全

在使用python的时候有时候总是忘记很多代码,这个是作为程序袁最头疼的事情,本人也是刚刚接触python,这几天也是用到这块,所以记录下来,已被需要时能够找到. 我的系统是: [email protected]:~$ uname -a Linux w 4.2.0-16-generic #19-Ubuntu SMP Thu Oct 8 15:35:06 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux 先看看自己的python安装路径,如果不知道的话可以根据下面的方

linux python tab 补全

第一步:查看python系统路径 [[email protected] tools]# python Python 2.7.12 (default, Jul  4 2016, 02:08:58)  [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2 Type "help", "copyright", "credits" or "license" for more informat

python交互模式下命令tab补全

python默认就可以进行tab补全命令行,在交互模式下,只要自己写个小小的tab.py模块即可:实现代码如下: #!/bin/env python  # -*- coding: utf-8 -*- # python startup file  import sys import readline import rlcompleter import atexit import os import platform # tab completion  readline.parse_and_bind