在使用python的时候有时候总是忘记很多代码,这个是作为程序袁最头疼的事情,本人也是刚刚接触python,这几天也是用到这块,所以记录下来,已被需要时能够找到。
我的系统是:
1 w@w:~$ uname -a
2 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安装路径,如果不知道的话可以根据下面的方法查看以下:
1 w@w:~$ python
2 Python 2.7.10 (default, Oct 14 2015, 16:09:02) 
3 [GCC 5.2.1 20151010] on linux2
4 Type "help", "copyright", "credits" or "license" for more information.
5 >>> import sys
6 >>> sys.path
7 ['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client']
既然找到了python的安装路径,把下面的代码传进去
 1 #!/usr/bin/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路径下:
 1 w@w:/usr/lib/python2.7/dist-packages$ vi tab.py 
 2 #!/usr/bin/python
 3 # python startup file
 4 import sys
 5 import readline
 6 import rlcompleter
 7 import atexit
 8 import os
 9 # tab completion
10 readline.parse_and_bind('tab: complete')
11 # history file
12 histfile = os.path.join(os.environ['HOME'], '.pythonhistory')
13 try:
14     readline.read_history_file(histfile)
15 except IOError:
16     pass
17 atexit.register(readline.write_history_file, histfile)
18 del os, histfile, readline, rlcompleter
我把文件传到/usr/lib/python2.7/dist-packages目录下,并且用tab.py命名。
1 w@w:~$ vi .bashrc
2 #for python    
3 export PYTHONSTARTUP=/usr/lib/python2.7/dist-packages/tab.py
4 #上面的路径和文件名必须和上面的保持一致。
5 w@w:~$ source .bashrc #启用上面的环境

转载于:https://www.cnblogs.com/wulaoer/p/5032301.html

unbtun python tab补全相关推荐

  1. centos7 python tab补全

    centos7 python tab补全 1.编写tab.py [vagrant@node100 ~]$ cat tab.py #!/usr/bin/python # python startup f ...

  2. python tab补全

    看视频发现讲课的老师python可以tab补全,网上找了一段代码 如下: [root@node01 data]#vi tab.py 1 #!/usr/bin/env python 2 # python ...

  3. linux python tab补全_python交互模式下实现tab自动补全功能

    建立.pythonstartup文件 $ cat .pythonstartup # cat ~/.pythonstartup # python startup file #!/usr/bin/env ...

  4. 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/py ...

  5. python学习------tab补全

    python学习------tab补全   python也可以进行tab键补全 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #!/usr/bin/env  ...

  6. python代码命令行tab补齐_Python语言交互模式下命令tab补全

    本文主要向大家介绍了Python语言交互模式下命令tab补全,通过具体的内容向大家展示,希望对大家学习Python语言有所帮助. python默认就可以进行tab补全命令行,在交互模式下,只要自己写个 ...

  7. MySQL(1)数据库介绍,配置MySQL的tab补全

    文章目录 一.数据库的基本概念 1.1 使用数据库的必要性 1.2 数据库的概念 1.2.1 数据(Data) 1.2.2 表 1.2.3 数据库 1.2.4 数据库管理系统(DBMS) 1.2.5 ...

  8. Python 之vim编写python自动补全

    Pydiction :vim - python自动补全插件 插件的安装如下: 1.下载插件包 https://github.com/vim-scripts/Pydiction 可以直接下载,也可git ...

  9. python自动补全库_叼炸天的库! 自动补全 Python 代码,能节省 60% 敲码时间

    近日,Reddit 上的一篇帖子引起了网友的热议.帖子作者「mlvpj」称: 「我们使用深度学习完成了一个简单的项目,可以自动进行 Python 代码补全.」 根据介绍,该项目基于 LSTM 模型,训 ...

  10. python自动补全库_这个库厉害了,自动补全Python代码,节省50%敲码时间

    近日,Reddit 上的一篇帖子引起了网友的热议.帖子作者「mlvpj」称: 「我们使用深度学习完成了一个简单的项目,可以自动进行 Python 代码补全.」 根据介绍,该项目基于 LSTM 模型,训 ...

最新文章

  1. java使用ireport生成报表_JasperReport(3)——Java简单使用IReport生成的文件建立报表...
  2. Android selector 使用
  3. Hibernate 中配置属性详解(hibernate.properties)
  4. 为什么C++(感谢waterwalk翻译)
  5. 10853k1_领导学基础_21秋考试
  6. 计算机专业英语词汇mp3,【听单词】计算机专业英语词汇音频106,计算机英语单词MP3...
  7. LuaForUnity6:Lua模块
  8. 解决从github下载项目速度过慢
  9. 【Swing 3】布局管理器与简单的聊天界面
  10. 交叉验证(Cross Validation)简介
  11. Hexo-Next主题配置
  12. 黑客郭盛华虚假新闻_每日新闻摘要:黑客闯入十个电信网络
  13. pandas shift函数的用法
  14. 6章7街构造函数和解析函数
  15. css选择器权重排序_css选择器的权重计算
  16. 微信小程序搜索wifi列表
  17. Python中条件判读语句if的使用详解
  18. 手摸手教你搭建免费图床
  19. 移动端购物车数据重新编译后数据消失
  20. 使用 BOL API 创建 SAP CRM IBASE 数据

热门文章

  1. php自学好还是培训,转行php选择自学还是培训
  2. day20线程Thread的sleep方法
  3. 个人开发者都可享受 无服务器计算颠覆收费
  4. window下python2和python3的共存
  5. Mysql 分组聚合实现 over partition by 功能
  6. ios icon尺寸问题
  7. spring mvc 上传文件
  8. BX+CX+loop
  9. C++--第9课 - 构造与析构 - 上
  10. Thrift IDL使用方式