0

I'm able to read a hexadecimal value from a file and multiply it, but how could I print it out as a hex too. Following prints value as an integer.

#!/usr/bin/env python2

f = open('file.dat', 'r')
f.seek(44)
value  = int(f.read(1), 16)*2
print value
f.close()

output: 12

V.Hedman
  • 29
  • 1
  • 1
  • 3
  • 2
    This question is not a duplicate because it's about formatting, the other questions are about conversion. – Robb Hoff Jul 08 '21 at 12:08

1 Answers1

9
print hex(value)

Just cast it to a hex value as you print it

MooingRawr
  • 4,901
  • 3
  • 24
  • 31