gpt4 book ai didi

python - 在终端中显示未存储在终端历史记录中的临时消息

转载 作者:行者123 更新时间:2023-12-01 05:56:54 26 4
gpt4 key购买 nike

我想创建一个命令行密码文件解密脚本,该脚本将在终端窗口中显示加密文件的内容最多 10 秒,之后文本将自动清除。

我不太确定此类功能的正确术语是什么,如果可以通过正确的搜索字符串找到答案,那么很抱歉。

最佳答案

如果您只需要显示一行“ secret ”输出,您可以使用“回车符”并覆盖该行。它不会在终端历史记录中留下任何痕迹。

from __future__ import print_function

import time
import sys

print("hello", end = '')
sys.stdout.flush()
time.sleep(1)
print("\rxxxxx")
sys.stdout.flush()

关于python - 在终端中显示未存储在终端历史记录中的临时消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12039243/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com