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

i am learning python, please can someone tell me how to fix it so i can slowly print each letter (like a type writer) but also working with the input

door1 = input('\n\nthere are 3 doors ahead of you, \n\nwhich one do you pick? \n\n1,2 or 3.')
for char in door1:
    sys.stdout.write(char)
    sys.stdout.flush()
    time.sleep(0.1)

我正在尝试获取代码以缓慢打印问题,但是当我尝试同时获取输入时我不知道如何执行此操作。

你几乎成功了!

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

之前,您以打字方式编写用户响应。你想这样写问题,所以我把 door1 改成了你的问题字符串。然后慢慢打印出来后,我把输入函数放在那里