0

How can I convert a string like '\\x41' to an escaped string like '\x41', using Python?

john_science
  • 6,325
  • 6
  • 43
  • 60
Kmd
  • 337
  • 2
  • 5
  • 18
  • possible duplicate of [Process escape sequences in a string in Python](http://stackoverflow.com/questions/4020539/process-escape-sequences-in-a-string-in-python) – Josh Lee Apr 01 '11 at 06:24

2 Answers2

3
>>> '\\x41'.decode('string_escape')
'A'

Gory details here.

Josh Lee
  • 171,072
  • 38
  • 269
  • 275
0

I don't really understand your question, but I'll try to give you some solutions.

  1. If you gonna print pure '\x41', you could just

print r'\x41'

  1. And if what you want is to print the 'A' out, pls do:

print u'\x41'

Linmic
  • 761
  • 4
  • 12