python file I/O with binary data
问题 I'm extracting jpeg type bits from mp3 data actually it will be album arts. I thought about using library called mutagen, but I'd like to try with bits for some practice purpose. import os import sys import re f = open(sys.argv[1], "rb") #sys.argv[1] gets mp3 file name ex) test1.mp3 saver = "" for value in f: for i in value: hexval = hex(ord(i))[2:] if (ord(i) == 0): saver += "00" #to match with hex form else: saver += hexval header = "ffd8" tail = "ffd9" this part of code is to get mp3 as