Possible Duplicate:
Process escape sequences in a string in Python
If I get this string, for example from a web form:
'\n test'
The '\n'
notation won't be interpreted as a line break. How an I parse this string so it becomes a line break?
Of course I can use replace
, split
, re
, etc, to do it manually.
But maybe there is a module for that, since I don't want to be forced to deal with all the \something
notations manually.
I tried to turn it into bytes then use str
as a construtor but that doesn't work:
>>> str(io.BytesIO(ur'\n'.encode('utf-8')).read())
'\\n'