0

I've been working on some code that will read a textfile with hexacode and decode it but I can't figure out how to readline() without making it read it as a string.

help would be really appreciated thx :)

Been trying to solve this problem for 4 hours now without rest lol. Now I think it's time to look for some help :)

  • 2
    Welcome to Stack Overflow! You need to post a [mre] if you want help with debugging. You can [edit] the question. – wjandrea Oct 05 '19 at 23:10
  • Possible duplicate of [Reading a binary file with python](https://stackoverflow.com/questions/8710456/reading-a-binary-file-with-python) – wiomoc Oct 05 '19 at 23:14

1 Answers1

0

This may help you

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

Original answer here

Daniel Rodríguez Meza
  • 1,167
  • 1
  • 8
  • 17
  • I get an error msg right now saying that utf-8 can't decode what I'm trying to decode do you think I need another encoder/ decodet than utf-8 for it to work?. It also sais invalid start byte. thx btw – Sebastian the coder Oct 05 '19 at 23:35