为了账号安全,请及时绑定邮箱和手机立即绑定

在加载屏幕期间请求用户输入

在加载屏幕期间请求用户输入

蝴蝶刀刀 2023-10-18 15:51:16
import sysimport timeloading = Trueloading_string = "." * 3sys.stdout.write("Press Enter to Launch")while loading:    for index, char in enumerate(loading_string):        sys.stdout.write(char)        sys.stdout.flush()        time.sleep(0.7)    sys.stdout.flush()    index += 1    sys.stdout.write("\b" * index + " " * index + "\b" * index)    sys.stdout.flush()我正在 cmd 中创建一个界面,要求用户输入,同时给他们一个“...” 加载屏幕。它打印出“Press Enter to Launch”,然后在短时间内打印出 3 个连续的点,然后重置为“Press Enter to Launch”,没有点,然后重复。问题是,Python 3 中的 input() 函数会停止所有代码,直到用户按下某个键(在本例中为 Enter)。我想知道是否可以运行模拟“...”的代码 加载屏幕,同时要求用户输入。
查看完整描述

1 回答

?
四季花海

TA贡献1811条经验 获得超5个赞

最终使用线程模块来运行代码,同时要求用户输入。



查看完整回答
反对 回复 2023-10-18
  • 1 回答
  • 0 关注
  • 66 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信