Skip to content Skip to sidebar Skip to footer

Convert File To Hex String Python

How would I convert a file to a HEX string using Python? I have searched all over Google for this, but can't seem to find anything useful.

Solution 1:

import binascii
filename = 'test.dat'
with open(filename, 'rb') as f:
    content = f.read()
print(binascii.hexlify(content))

Post a Comment for "Convert File To Hex String Python"