0

I'm using http.client.HTTPConnection request result in Python. Result is like :

\u000aFull command = \/opt\/ericsson\/amos\/moshell\/mobatch \u000a Hello

I want to convert this into standart text for my next parsing operation

response = connection.getresponse()
html_response = response.read().decode('ascii')

What I'm expecting here as result is

Full command = /opt/ericsson/amos/moshell/mobatch
Hello

But its not even converts, I directly get the same thing. I already tried regular expression replacements but I dont want to struggle in all characters in ASCII 10 list.

Louis
  • 766
  • 7
  • 10
Omrum Cetin
  • 1,320
  • 13
  • 17

1 Answers1

1

Try this

  1. decode with unicode_escape (docs)
  2. remove extra back slashes

sample code:

s = '\u000aFull command = \/opt\/ericsson\/amos\/moshell\/mobatch \u000a Hello'  
print s.decode('unicode_escape').replace('\\', '')

Full command = /opt/ericsson/amos/moshell/mobatch  
 Hello
Louis
  • 766
  • 7
  • 10