开发者

Python: read user-input directly from the prompt

开发者 https://www.devze.com 2023-01-20 02:50 出处:网络
I have to validate user-i开发者_StackOverflow社区nput from stdin that is not going to be entered by hitting the Enter-key.

I have to validate user-i开发者_StackOverflow社区nput from stdin that is not going to be entered by hitting the Enter-key. So readline() and other Enter-dependent functions are of no use to me.

Practically the promt will be filled, and each keystroke has to be handled as an event. How do I get access to the promt buffer's contents?


I'm unclear what you mean by "prompt", but it sounds like you need to respond to individual key-presses, rather than textual input.

This is covered in the Python FAQ under "How do I get a single keypress at a time?"


See if it helps

http://code.activestate.com/recipes/134892/

0

精彩评论

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