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 newline character (double "\"):</p>

<pre><code>rep=["[","u'","\\n"]
for r in rep:
    wr=wr.replace(r,"")
</code></pre>

<p>This is the same as @cricket_007's answer, however, the second part from his answer does not work for me. To my knowledge, str.replace() does not support these kind of regular expression lookups.</p>

python parsing strip