之间的差异`编解码器.StreamReader`以及`io.TEXTIO包装器`

2024-06-17 10:52:25 发布

您现在位置:Python中文网/ 问答频道 /正文

在二进制流上使用codecs.StreamReaderio.TextIOWrapper有什么区别?你知道吗

#!/usr/bin/env python3

import codecs
import io

stream = io.BytesIO(b'abc')
#reader = codecs.getreader('utf-8')(stream)
reader = io.TextIOWrapper(stream)
print(reader, reader.read())

Tags: ioimportenvstreambinusr二进制python3