我写了以下法典,以撰写档案内容,
with codecs.open(name,"a","utf8") as myfile:
myfile.write(str(eachrecord[1]).encode( utf8 ))
myfile.write(" ")
myfile.write(str(eachrecord[0]).encode( utf8 ))
myfile.write("
")`
上述法典在撰写单编码特性时并不适当。 我不断发现错误
统一编码 rror: ascii codec can t encode nature u xe1 in post 6: ordinal not in range (128)
任何人都看一看一去做错了吗?
<><>Edit>:
with codecs.open(name,"a","utf8") as myfile:
myfile.write(unicode(eachrecord[1]))
myfile.write(" ")
myfile.write(unicode(eachrecord[0]))
myfile.write("
")
这起作用。 感谢所有迅速的评论和答复,这确实有助于。 我没有认识到,在你对我说谎之前,猪口有单条码选择。