> import string > str = open("binoranydata","rb").read() > hexStr="" > for x in range(0, len(str)): > hexStr=hexStr+hex(ord(str[x]))+"\n" > print hexStr If the file is very long, do not do this -- it is o(n*n) == slow. As other suggested, make a list of chunks and then join with nothing or any separator you want.