Remove \n from python string
<p>I have scraped a webpage using beautiful soup. 
I'm trying to get rid of a '<code>\n</code>' character which isnt eliminated despite whatever I try. </p>

<p>My effort so far:</p>

<pre><code>wr=str(loc[i-1]).strip()
wr=wr.replace(r"\[|'u|\\n","")
print(wr)
</code></pre>

<p>Output:</p>

<pre><code>    [u'\nWong; Voon Hon (Singapore, SG
Kandasamy; Ravi (Singapore, SG
Narasimalu; Srikanth (Singapore, SG
Larsen; Gerner (Hinnerup, DK
Abeyasekera; Tusitha (Aarhus N, DK
</code></pre>

<p>How do I eliminate the [u'\n? What am I doing wrong?</p>

<p>The full code is <a href="http://pastebin.com/Q9xREXUV" rel="nofollow">here</a>. </p>

<p>You need to escape the backslash or use a raw string. Otherwise, it's a newline character, not a literal <code>\n</code></p>

<p>Also, I don't think beautifulsoup is outputting unicode strings. You see the string representation in python as <code>u'blah'</code></p>

<p>And you shouldn't need a list of elements to remove. The expression can be </p>

<pre><code>r"\[|'u|\n"
</code></pre>

python parsing strip