python newbie having strangeness

Tony C cappy2112 at yahoo.com
Fri Feb 27 20:22:10 EST 2004


Joe F. Blow <dood at dood.com> wrote in message > count=binlist=0

this may be of some use in converting from hex to decimal

file=open("file.text")
WholeFile= file.readlines()
WholeFile.close()

# now, you have to search for the location of the decimal numbers
# I can't specify how to do that, without knowing what your input file looks #like

#but once you have a string as in

HexStr ="123ABCDE" #implied is that this string was read from a file
(you MUST strip off any leading 0x, or trailing H or h, before proceeding)

You can convert it to a decimal string by
DecStr = "%lu" % long(HexStr,16)
and to an integer by
DecNum = long(DecStr)



More information about the Python-list mailing list