raw_input 不会在 readline 中留下历史记录

发布于 2024-07-29 18:44:37 字数 60 浏览 4 评论 0原文

有没有一种方法可以使用 raw_input 而不在阅读行历史记录中留下符号,以便在制表符完成时不会显示它?

Is there a way of using raw_input without leaving a sign in the readline history, so that it don't show when tab-completing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

且行且努力 2024-08-05 18:44:37

您可以创建一个类似的函数

import readline

def raw_input_no_history():
    input = raw_input()
    readline.remove_history_item(readline.get_current_history_length()-1)
    return input

并调用该函数而不是 raw_input。 您可能不需要负 1,具体取决于您从何处调用它。

You could make a function something like

import readline

def raw_input_no_history():
    input = raw_input()
    readline.remove_history_item(readline.get_current_history_length()-1)
    return input

and call that function instead of raw_input. You may not need the minus 1 dependent on where you call it from.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文