Ray*_*Ray 9 python input readline
有没有办法以编程方式中断Python的raw_input?具体来说,我想向用户提示,但也要监听套接字描述符(例如使用select)并中断提示,输出内容,如果数据进入套接字,则重新显示提示.
使用raw_input而不是简单地在sys.stdin上执行select的原因是我想使用readline模块为提示提供行编辑功能.
据我所知......“有点”。
raw_input is blocking so the only way I can think of is spawning a subprocess/thread to retrieve the input, and then simply communicate with the thread/subprocess. It's a pretty dirty hack (at least it seems that way to me), but it should work cross platform. The other alternative, of course, is to use either the curses module on linux or get this one for windows.
| 归档时间: |
|
| 查看次数: |
1755 次 |
| 最近记录: |