Python Write bytes to file
If you want to write bytes then you should open the file in binary mode.
f = open('/tmp/output', 'wb')
Write bytes and Create the file if not exists:
f = open('./put/your/path/here.png', 'wb')
f.write(data)
f.close()
wb
means open the file in write binary
mode.