简体   繁体   中英

Threading + raw_input in Python

I've got a Python script that does a bunch of things in a single subthread, and I'd like the main thread to spit out raw_input("> ") (to be handled by the main thread), and keep that input on the bottom of the console, while the subthread prints things above. I originally thought I could use something like print "\\b\\b" + message + "\\n> " in the subbthread, but that doesn't account for things like characters the user has typed in. So, the console would look something like this:

[22:04] Started
[22:06] Some output
[22:06] Some more output
> 

Is this possible?

除了curses建议之外,你可能还想看看urwid ,一个更高级别,更友好的python库,用于处理控制台输出。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM