将连接对象编码和解码为流
项目描述
将JSON迭代器编码为流
def gen_records():
yield b'{"foo": "bar"}'
yield b'{"baz": [1, 2, 3]}'
stream = streamcat.iterator_to_stream(gen_records())
# `stream` can then be used just like any other `io.RawIOBase`
with open('/tmp/jsoncat', 'wb') as destination:
shutil.copyfileobj(stream, destination)
将流解码为生成器
decoder = json.JSONDecoder()
with open('/tmp/jsoncat', 'rb') as source:
records = streamcat.stream_to_iterator(source, decoder)
for record in records:
print(record)
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分布
streamcat-0.2.1.tar.gz (4.1 kB 查看哈希)
构建分布
streamcat-0.2.1-py2.py3-none-any.whl (3.7 kB 查看哈希)
关闭
streamcat-0.2.1.tar.gz的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 469dd7d54949a242cdb83012d540c9fd1e8dc50e13898c24121c0edac2f6d07a |
|
MD5 | 7acdefd66ba68a9d7707150eebf0bfa5 |
|
BLAKE2b-256 | 3f15fb8bb1e641f95a358ce3fc09c4a78efcc634078ef3df7a480c9f69d4721a |
关闭
streamcat-0.2.1-py2.py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | fcfde8809c24e490ff8414261f7475a695c0d34a6497fbc56a719a0baf1e4147 |
|
MD5 | b901e1d472488420cb32fcf0c1efb408 |
|
BLAKE2b-256 | 7ace34ef9ee80186316de469f460b0ccbbc9c648bb26b8d7216ec163e4b7b7bc |