With Python I know that the \"\\n\" breaks to the next line in a string, but what I am trying to do is replace every \",\" in a string with a \'\\n\'. Is that possible? I am kin
You can insert a literal \n
into your string by escaping the backslash, e.g.
>>> print '\n'; # prints an empty line
>>> print '\\n'; # prints \n
\n
The same principle is used in regular expressions. Use this expresion to replace all ,
in a string with \n
:
>>> re.sub(",", "\\n", "flurb, durb, hurr")
'flurb\n durb\n hurr'