0

I try to read from windows console utf-8 letters.

I have the code follows:

import codecs
sys.stdin = codecs.getreader('utf-8')(sys.stdin)

if __name__ == '__main__':    
    print 'query=',
    query = sys.stdin.readline()
    print query 

But there is a strange thing:

After pressing the enter button the execution of the stdin.readline() or raw_input() or input() functions will not stop.

What do I do wrong? Or how to send eof() to stop input from console in this case?

Remi Guan
  • 21,506
  • 17
  • 64
  • 87
Kirill Golikov
  • 1,354
  • 1
  • 13
  • 27

1 Answers1

1

On my Mac, hitting ^D (Ctrl-D) twice does the trick. Not sure if this will work across systems, but give it a shot.

BallpointBen
  • 9,406
  • 1
  • 32
  • 62
  • I found next http://stackoverflow.com/questions/1118957/c-how-to-simulate-an-eof#comment53315664_1118966 In Windows my code will not work. It so sad. – Kirill Golikov Oct 31 '15 at 08:53