[Tutor] REPL format

Alan Gauld alan.gauld at btinternet.com
Sun Apr 26 02:43:23 CEST 2015


On 26/04/15 00:38, Jim Mooney wrote:

> ...it's interesting that although
> HTML is case-free, you have to get the case right for the java server page.
> getbusesforroute.jsp doesn't work.

That's because its a file name and has nothing to do with HTML.
The HTML is what's inside the file.

> ?import urllib.request
> u = urllib.request.urlopen('
> http://ctabustracker.com/bustime/map/getBusesForRoute.jsp?route=22')
> data = u.read()

What do you get if you print data here?
That will tell you whether its something to do with that you
get from the server or whether its to do with what you are
doing to the data when you save/read it.

> f = open('rt22.xml', 'wb')
> f.write(data)
> f.close()
>
> f = open('rt22.xml', 'rb')
> transit_info = str(f.read(), encoding='utf-8')
>
>>>> transit_info
> ('<?xml version="1.0"?>\r\n'
>   '\r\n'
>   '\r\n'
>   ... bunch of stuff ...
>   '\t\t\t<wid2>222</wid2>            \t\r\n'
>   '\t\t</bus>\r\n'

I can't reproduce this format in the interpreter so I don't
know what's going on. I seem to recall you are using Python 3,
is that correct?

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list