Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?
Laurent Pointal
laurent.pointal at free.fr
Sun Jul 12 13:54:01 EDT 2015
Simon Evans wrote:
<zip>
> ---------------------------------------------------------------------
>>>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r") as
You seem to run Python under Windows.
You have to take care of escape mechanism beyond \ char in string literals
(see Python docs).
By chance, \B and \e are not recognized as escape sequences, so they are
left as is. But \a \b \f \n \r \t \v \x will be processed differently
Double \ in your string:
"C:\\Beautiful Soup\\ecologicalpyramid.html"
Or use a raw string by prepending a r to disable escape sequences:
r"C:\Beautiful Soup\ecologicalpyramid.html"
<zip>
A+
Laurent.
More information about the Python-list
mailing list