python3以特定字符集读写文件
>>> import codecs;
>>> out.close();
>>> out=codecs.open('test2.txt','w','utf-8');
>>> out.write("This is 测试写入中文,而且用的是UTF-8字符集.");
>>> out.close();
>>> import codecs;
>>> out=codecs.open('test2.txt','r','utf-8');
>>> for line in out:
print(line);
This is 测试写入中文,而且用的是UTF-8字符集.
>>> out.close();
阅读(4258) | 评论(0) | 转发(0) |