F
Florian Wilhelm
I have some easy questions, but I cant figure them out:
I want to read exactly one char from stdin, there should
be no need to hit enter.
import sys
print "Input: (y/N) ",
input = sys.stdin.read(1)
print "Your input:", input
This code has following problems:
1) I need to hit enter, although I read only one char?!?
2) The complete output is:
Input: (y/N) y
Your input: y
Why does the whitespace char appear in front of "Your input..."?
I guess it has something to do with not causing a linebreak
after "Input: (y/N) ", but I want no linebreak...
Any suggestions?
Regards,
Florian
I want to read exactly one char from stdin, there should
be no need to hit enter.
import sys
print "Input: (y/N) ",
input = sys.stdin.read(1)
print "Your input:", input
This code has following problems:
1) I need to hit enter, although I read only one char?!?
2) The complete output is:
Input: (y/N) y
Your input: y
Why does the whitespace char appear in front of "Your input..."?
I guess it has something to do with not causing a linebreak
after "Input: (y/N) ", but I want no linebreak...
Any suggestions?
Regards,
Florian