I did this:
from urllib import urlopen
import nltk
url = http://myurl.com
html = urlopen(url).read()
cleanhtml = nltk.clean_html(html)
I now have a long string in python which is full of text interrupted periodically by windows newlines /r/n, and I simply want to remove all of the occurrences of /r/n from the string using a regular expression. First I want to replace it with a space. As such, I did this:
import re
textspaced = re.sub("'\r\n'", r"' '", cleanhtml)
…it didn’t work. So what am I doing wrong?
Just a small syntax error:
should work.