"Disabling" raw string to print newlines

kuratkull at kuratkull.com kuratkull at kuratkull.com
Mon May 19 10:29:53 EDT 2008


On May 19, 4:01 pm, Paul McGuire <pt... at austin.rr.com> wrote:
> On May 19, 4:54 am, kuratk... at kuratkull.com wrote:
>
>
>
> > Hello,
>
> > ***************
> > import urllib2
> > import re
> > import string
> > import sys
>
> > url = "http://www.macgyver.com/"
> > request = urllib2.Request(url)
> > opener = urllib2.build_opener()
> > html = opener.open(request).read()
>
> > match = re.compile("<PRE>(.+)</PRE>", re.DOTALL)
>
> > out = match.findall(html)
>
> > print out
> > **************
This worked like a charm! :)
I used Python about a year ago and I have forgotten some of its
properties.

Thanks to both of you!
-kuratkull

>
> > I would like to print out string with formatting, but as I read, the
> > string is made into a raw string when using re.
> > How could I disable or bypass this?
>
> > I googled for an hour and couldn't find a solution.
>
> > Thank you in advance.
>
> Change your print statement to:
>
> print out[0]
>
> -- Paul




More information about the Python-list mailing list