Fix Python 2 TypeError: write() argument 1 must be unicode, not str (see issue #2856)
This commit is contained in:
parent
e1132672ee
commit
894ac21532
|
@ -32,6 +32,11 @@ def write_file(name, data):
|
|||
try:
|
||||
with open(name, 'w', encoding='utf-8') as f:
|
||||
# write the data
|
||||
try:
|
||||
# Python 2
|
||||
f.write(data.decode('utf-8'))
|
||||
except Exception as e:
|
||||
# Python 3
|
||||
f.write(data)
|
||||
except IOError as e:
|
||||
(errno, strerror) = e.args
|
||||
|
|
Loading…
Reference in New Issue