将Unicode文本写入文本文件?
import codecs f = codecs.open('out.txt', mode="w", encoding="iso-8859-1")f.write(all_html.encode("iso-8859-1", "replace"))
UnicodeDecodeError:‘ASCII’编解码器无法解码12286位置的字节0xa0:序数不在范围内(128个)
部分解决办法:
row = [unicode(x.strip()) if x is not None else u'' for x in row]all_html = row[0] + "<br/>" + row[1]f = open('out.txt', 'w')f. write(all_html.encode("utf-8"))
Qur’an
jeck猫
相关分类