Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Fix ascii codec issue when outputing pascal file
Browse files Browse the repository at this point in the history
  • Loading branch information
tzutalin committed Jan 29, 2017
1 parent b7913f4 commit 1fb28d8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libs/pascal_voc_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from xml.etree import ElementTree
from xml.etree.ElementTree import Element, SubElement
from lxml import etree
import codecs


class PascalVocWriter:
Expand Down Expand Up @@ -100,9 +101,9 @@ def save(self, targetFile=None):
self.appendObjects(root)
out_file = None
if targetFile is None:
out_file = open(self.filename + '.xml', 'w')
out_file = codecs.open(self.filename + '.xml', 'w', encoding='utf-8')
else:
out_file = open(targetFile, 'w')
out_file = codecs.open(targetFile, 'w', encoding='utf-8')

prettifyResult = self.prettify(root)
out_file.write(prettifyResult.decode('utf8'))
Expand Down

0 comments on commit 1fb28d8

Please sign in to comment.