0

I get the users Input with raw_input(). This Input is stored in a variable. How can I cast this variable to be Unicode. I Need this for further executions.

 userinput = raw_input("Hello. What is your Name?")
Judith
  • 57
  • 3
  • 8

1 Answers1

1

Jst call the "decode" method on the result of "raw_input". Matter is, you need to know the encoding of the terminal where the input was made:

import sys

value = raw_input("bla bla bla").decode(sys.stdin.encoding or 'utf-8')

But yu really should use Python 3

jsbueno
  • 86,446
  • 9
  • 131
  • 182