mirror of
https://github.com/moshix/mvs.git
synced 2026-01-11 23:43:00 +00:00
Update hexdump.py
This commit is contained in:
parent
8a615a9725
commit
138d1984e5
@ -23,13 +23,17 @@ import sys
|
||||
def hexdump(filename):
|
||||
with open(filename, 'rb') as f:
|
||||
counter = 0
|
||||
mem_f= "{:04d}".format(counter)
|
||||
print("Dec Hex Content hex Content asci")
|
||||
print("---- --------- ----------------------------------------------- ------------")
|
||||
while True:
|
||||
chunk = f.read(16)
|
||||
if not chunk:
|
||||
break
|
||||
mem_f= "{:04d}".format(counter)
|
||||
hexdata = ' '.join(f'{byte:02X}' for byte in chunk)
|
||||
textdata = ''.join(chr(byte) if 32 <= byte <= 126 else '.' for byte in chunk)
|
||||
print(f'{counter:08X} {hexdata:<48} {textdata}')
|
||||
print(str(mem_f) +" " + f'{counter:08X} {hexdata:<48} {textdata}')
|
||||
counter += 16
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user