我正在学习python,请有人告诉我如何修复它,这样我就可以慢慢打印每个字母(就像打字一样),但也可以处理输入


door1 = input('nnthere are 3 doors ahead of you, nnwhich one do you pick? nn1,2 or 3.')
for char in door1:
sys.stdout.write(char)
sys.stdout.flush()
time.sleep(0.1)

我正试图让代码慢慢打印问题,但当我试图同时获得输入时,我不知道如何做到这一点。

你几乎成功了!

import time,sys
door1 = 'nnthere are 3 doors ahead of you, nnwhich one do you pick? nn1,2 or 3.'
for char in door1:
sys.stdout.write(char)
sys.stdout.flush()
time.sleep(0.1)
response = input()

以前,你是用打字的方式写用户回复的。你想把问题写成那样,所以我把door1改成了你的问题串。然后慢慢打印后,我把输入功能放在那里。

相关内容

最新更新