On Sat, Jan 4, 2014 at 2:26 PM, Alex Kleider <aklei...@sonic.net> wrote: > The output I get on an Ubuntu 12.4LTS system is as follows: > alex@x301:~/Python/Parse$ ./IP_info.py3 > Exception raised. > IP address is 201.234.178.62: > Country: COLOMBIA (CO); City: b'Bogot\xe1'. > Lat/Long: 10.4/-75.2833 > > > I would have thought that utf-8 could handle the 'a-acute'.
b'\xe1' is Latin-1. Look in the response headers: url = 'http://api.hostip.info/get_html.php?ip=201.234.178.62&position=true' >>> response = urllib.request.urlopen(url) >>> response.headers.get_charsets() ['iso-8859-1'] >>> encoding = response.headers.get_charsets()[0] >>> sp = response.read().decode(encoding).splitlines() >>> sp[1] 'City: Bogotá' _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor