How to write bytes to file? October 14, 2022 by Tarik If you want to write bytes then you should open the file in binary mode. f = open('/tmp/output', 'wb')