Convert File to HEX String Python

后端 未结 1 1371
野性不改
野性不改 2020-12-29 05:12

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.

相关标签:
1条回答
  • 2020-12-29 05:30
    import binascii
    filename = 'test.dat'
    with open(filename, 'rb') as f:
        content = f.read()
    print(binascii.hexlify(content))
    
    0 讨论(0)
提交回复
热议问题