0

I have been trying to receive input in a way that won't stuck my program (msvcrt instead of recv). Yet, my program isn't working and I'm having trouble understanding why.

I tried writing a code (that somehow works on my friend's computer, but not on mine).

import msvcrt

print ("enter something")

line = b""
while True:
  ch = msvcrt.getwch()
  print "2"
  if ch == b'\r':
    print (line.decode('latin-1'))
    break

  line = line + ch
  print (ch.decode('latin-1'))
martineau
  • 119,623
  • 25
  • 170
  • 301
  • How is it not working? – martineau Jul 20 '19 at 19:52
  • 1
    `msvcrt.getwch` reads input directly from the console of a process. It does not read from `sys.stdin`, so it will not work in an IDE or any other environment that doesn't use a console, such as an MSYS2 terminal (e.g. git-bash). – Eryk Sun Jul 21 '19 at 01:23

0 Answers0