The third parameter can be directly added to
the
() opened by py36 with as , encoding = 'utf-8'
py27
uses .encode ('utf-8') after something inside f.write
with open(os.path.join(paths,'r2',
os.path.splitext(os.path.basename(ima))[0])+ ".txt", "w", encoding='utf-8') as f:
f.write("The time is:{}s".format(time.time() - t)+"\n")
for key in result:
# f.write(result[key][1].encode("utf-8")) ##py27
f.write(result[key][1])
f.write("\n")
[Refer-CB] (https://www.cnblogs.com/baojun2014/p/9085533.html)