开发者

Threading + raw_input in Python

开发者 https://www.devze.com 2023-04-06 17:53 出处:网络
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 t

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 s开发者_开发问答omething 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?


In addition to the curses suggestions, you might want to take a look at urwid, a higher-level, more python friendly library for dealing with console output.

0

精彩评论

暂无评论...
验证码 换一张
取 消