You need to decode the returned value to a str
object:
msvcrt.getch().decode('ASCII')
would interpret the byte as a ASCII codepoint, for example. You may need to use a different encoding depending on the keyboard layout and locale, but the msvcrt.getch()
API specifically only deals with ASCII characters according to the documentation:
The module implements both the normal and wide char variants of the console I/O api. The normal API deals only with ASCII characters and is of limited use for internationalized applications. The wide char API should be used where ever possible.
You probably want to use msvcrt.getwch()
instead to get Unicode values directly; the method supports more than just ASCII codepoints as well.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…