[Tutor] encoding question
Steven D'Aprano
steve at pearwood.info
Sun Jan 5 23:26:57 CET 2014
On Sun, Jan 05, 2014 at 11:02:34AM -0500, eryksun wrote:
> Danny walked you through the XML. Note that he didn't decode the
> response. It includes an encoding on the first line:
>
> <?xml version="1.0" encoding="ISO-8859-1" ?>
That surprises me. I thought XML was only valid in UTF-8? Or maybe that
was wishful thinking.
> tree = ET.fromstring(response.read())
In other words, leave it to ElementTree to manage the decoding and
encoding itself. Nice -- I like that solution.
--
Steven
More information about the Tutor
mailing list