[Tutor] Low Level Reads

Justin Ko jko@andover.edu
Sat, 28 Apr 2001 15:41:30 -0400


         Hey everyone,
         I've got a question about reading from files. I'm working on a 
module to read ID3v2 tags off of mp3 files. When I read data from the mp3 
file, the data is returned as a string of hex. For instance...


         >>> file = open("some.mp3")
         >>> file.seek(0, 0)
         >>> header = file.read(11)
         >>> header
         'ID3\x03\x00\x00\x00\x00\x0ejT'
         >>>

         How can i perform the conversion from hex to base 10? More 
specifically, I need to obtain base 10 values for header[3:5]. int() 
doesn't seem to like hexadecimal values. Neither does str() or float()...

_justin Ko