在python 2中.我可以这样做:
import sys, array
a = array.array('B', range(100))
a.tofile(sys.stdout)
但现在我得了TypeError: can't write bytes to text stream
分.有什么我应该使用的秘密编码吗?
在python 2中.我可以这样做:
import sys, array
a = array.array('B', range(100))
a.tofile(sys.stdout)
但现在我得了TypeError: can't write bytes to text stream
分.有什么我应该使用的秘密编码吗?
更好的方法:
import sys
sys.stdout.buffer.write(b"some binary data")