0

It actually goes further than the title suggests, if I have raw_input() anywhere in main, nothing will happen until the input has been entered by the user including any function calls or outputs that should occur before raw_input is called. Here's a very simple example of my code and what occurs when it's run.

def main():
    answer = raw_input('Continue?')
    print 'You said: ', answer

When I run it: (nothing comes on screen)

(user input)

blah blah blah

(Output):

Continue?You said: blah blah blah

I apologize if this is some sort of absurdly simple fix, but I've searched quite a bit and not been able to find anything. I'm running Windows 7 64 bit with Python 2.7 if that has anything to do with it. Also, identical code works perfectly in the interpreter which is kind of weird. If you guys can figure this out, that would be great!

Thanks, Will

Edit: Just tried to work around by using sys.stdin.readline() but had the same issue.

4

1 回答 1

0

看起来这是一个缓冲问题。我通过输入'-u'命令解决了它。

于 2012-07-24T19:11:57.293 回答