V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
northisland
V2EX  ›  问与答

我想用 python 做一个能用 tab 键给出下一步提示的脚本,像 make+tab 那样的。可以么?

  •  
  •   northisland · 2016-10-09 23:04:46 +08:00 · 1834 次点击
    这是一个创建于 2767 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我想用 python 做一个能用 tab 键给出下一步提示的脚本,像 make+tab 那样的。

    但我不知道用什么方法。

    又不会把这个想法用英文表达出来,去 google 。

    google (python press tab key to pop up what to do next ?

    俺英语说的不native,提出的问题,谷歌娘也理解不能。)

    求各位提示啦。谢谢

    2 条回复    2016-10-10 00:25:29 +08:00
    jigloo
        1
    jigloo  
       2016-10-09 23:09:15 +08:00   ❤️ 1
    给你看个 bbfreeze 的代码。 https://github.com/schmir/bbfreeze/blob/master/bbfreeze/py.py#L74 当然这货也是抄别人的。
    注意关键字 rlcompleter 和 readline
    billlee
        2
    billlee  
       2016-10-10 00:25:29 +08:00   ❤️ 1
    你是要在 python 里面起个 readline 来实现这个功能,还是外部的 shell 调用你的 python 时自动补全?如果是后者你需要的是 shell 脚本。
    http://www.tldp.org/LDP/abs/html/tabexpansion.html
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3449 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 12:08 · PVG 20:08 · LAX 05:08 · JFK 08:08
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.