En python 2.x, je pourrais faire ceci:
import sys, array
a = array.array('B', range(100))
a.tofile(sys.stdout)
Maintenant, cependant, j'obtiens un TypeError: can't write bytes to text stream. Y a-t-il un encodage secret que je devrais utiliser?
os.writefonctionnera à la fois sur Py2 et Py3.