I'm trying to convert a string coming from raw_input() into a "string of bytes". When I type the variable manually (in the code) it works fine, as it returns me a length of 5. However, when I try to enter the "string of bytes" with raw_input() it returns me a length of 20.
>>> x='\xB2\xB2\xB3\xB4\x01'
>>> len(x)
5
>>> x=raw_input()
\xB2\xB2\xB3\xB4\x01
>>> len(x)
20
I would like to know why this is happening and how can I fix it. Thanks in advance.
raw_input()treats your input literary as['\', 'x', 'B', '2' ... ]. String and array of bytes is same thing in Python 2.7.x?