How to write binary to a file in Python | The Dev Tool |

You can use the bytearray to convert a list of integers which are binary format (e.g. asii). Afterwards you can write it to a file:

fileBytes = [23, 12, 33]
data = bytearray(fileBytes)
with open (\"filename.txt\", \"wb\") as f:

Created by: martin


This page is only partially working without JavaScript. It will show content, but the tools and interactivity cannot be shown without JavaScript enabled. Please enable JavaScript for this page. About Us