问题
I am learning Python, and I have decided to make some practise by coding a mini chat in terminal, with a server and a client. But there is a problem, to make a real chat, the client must be able to type, send and receive messages in the same time like that:
//MESSAGES
>bla bla to send
So messages are scrolling while in the bottom of the shell, there's my input.
I have searched the web how to make that, maybe the multi-threading, no. The input() fonction blocks the process.
If you have an answer to my question, it'll be great! Thanks in advance!
回答1:
On Unix systems, you might want to check out curses, which is a library designed to do this type of thing. Python has a module for it in the standard library.
There is a good tutorial on using curses in the docs. This also suggests the console module for Windows users.
来源:https://stackoverflow.com/questions/12010446/use-input-and-print-at-the-same-time-like-in-a-chat