标签: unicode python-3.x
我发现Python3的open("filename", "r", encoding="ascii", errors="surrogateescape")很有用。如何包装io.BytesIO()(或任何非实际文件的字节源)来创建具有相同解码行为的文本模式文件类对象?
open("filename", "r", encoding="ascii", errors="surrogateescape")
io.BytesIO()
答案 0 :(得分:4)
这就是TextIOWrapper的作用。