How to write binary data to stdout in python 3? November 23, 2022 by Tarik A better way: import sys sys.stdout.buffer.write(b"some binary data")