Skip to content

Instantly share code, notes, and snippets.

@butsugiri
Created November 11, 2016 12:52
Show Gist options
  • Select an option

  • Save butsugiri/0f702829e1d384e7116eee8481de8d1c to your computer and use it in GitHub Desktop.

Select an option

Save butsugiri/0f702829e1d384e7116eee8481de8d1c to your computer and use it in GitHub Desktop.
shift_jisとヘッダーのエンコーディングに記述されたshift_jisなxmlファイルとうまくやる方法
text = open("00001.dict", encoding="shift-jis").read()
tree = etree.fromstring(text.encode("shift-jis"))
print(etree.tostring(tree, encoding="utf-8", xml_declaration=True, doctype="<!DOCTYPE gda>").decode("utf8"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment