Skip to content

Instantly share code, notes, and snippets.

@mrluanma
Created September 30, 2014 07:29
Show Gist options
  • Save mrluanma/c21821eabb5c29a889fc to your computer and use it in GitHub Desktop.
Save mrluanma/c21821eabb5c29a889fc to your computer and use it in GitHub Desktop.
# -*- coding: utf-8
from lxml import etree as ET
from io import BytesIO
gb2312_xml = u"""<?xml version="1.0" encoding="gb2312" ?>
<node>中文</node>""".encode("gb2312")
print(ET.tostring(ET.parse(BytesIO(gb2312_xml)), encoding="utf-8"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment