相关疑难解决方法(0)

如何在python 3中将二进制数据写入stdout?

在python 2.x中,我可以这样做:

import sys, array
a = array.array('B', range(100))
a.tofile(sys.stdout)
Run Code Online (Sandbox Code Playgroud)

然而,现在,我得到了一个TypeError: can't write bytes to text stream.我应该使用一些秘密编码吗?

python python-3.x

88
推荐指数
3
解决办法
4万
查看次数

标签 统计

python ×1

python-3.x ×1