Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Writing Bytes to a File in python

# Pass "wb" to write a new file, or "ab" to append
with open("test.txt", "wb") as binary_file:
    # Write text or bytes to the file
    binary_file.write("Write text by encoding
".encode('utf8'))
    num_bytes_written = binary_file.write(b'xDExADxBExEF')
    print("Wrote %d bytes." % num_bytes_written)
Source by www.devdungeon.com #
 
PREVIOUS NEXT
Tagged: #Writing #Bytes #File #python
ADD COMMENT
Topic
Name
9+2 =