如何从 Python 的 ByteIO 获取二进制数据
使用 BytesIO 实例的 getvalue() 函数。示例:
bytesio_example.py
#!/usr/bin/env python3
from io import BytesIO
myio = BytesIO()
myio.write(b"Test 123")
print(myio.getvalue()) # 打印 b'Test 123'Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow