In Python, is it possible to request user input with input() in the console while simultaneously printing out text in the line BEFORE the prompt?
It should look something like this:
Text 1
Text 2
Text 3
Please enter something: abc
Whenever new text is printed, it should be printed after the previous text and before the input() prompt. Also, it should not interrupt the user entering the text.
Therefore, after printing "Text 4" the console should look like this:
Text 1
Text 2
Text 3
Text 4
Please enter something: abc
Is that possible to do in Python without using any external libraries?
I have already tried using
, and similar codes as well as threading.
I also know that I will probably need to have one thread printing out the text while I have another one requesting the user input.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…