ITPub博客

首页 > IT职业 > IT职场 > Python 自动补全模块

Python 自动补全模块

IT职场 作者:yellowduck007 时间:2021-09-09 09:34:11 0 删除 编辑

  • for linux

#!/usr/bin/env python # python startup file import sysimport readlineimport rlcompleterimport atexitimport 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:    passatexit.register(readline.write_history_file, histfile)del os, histfile, readline, rlcompleter

把上面代码保存为tab.py放置在当前系统全局环境变量下,可以使用print(sys.path)查看,如:/usr/lib64/python2.6/site-packages

  • for mac

import sysimport readlineimport rlcompleterif sys.platform == 'darwin' and sys.version_info[0] == 2:    readline.parse_and_bind("bind ^I rl_complete")else:    readline.parse_and_bind("tab: complete")  # linux and python3 on macfor mac

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2611/viewspace-2804790/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-16

  • 博文量
    88
  • 访问量
    983