Reading a binary file in as hex
Terry Reedy
tjreedy at udel.edu
Wed Oct 18 00:26:18 EDT 2000
More information about the Python-list mailing list
Wed Oct 18 00:26:18 EDT 2000
- Previous message (by thread): Reading a binary file in as hex
- Next message (by thread): Connecting to running win32com
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> 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.
- Previous message (by thread): Reading a binary file in as hex
- Next message (by thread): Connecting to running win32com
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list