- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
hxStr = []
for x in range(256):
hxStr.append('{:02X}'.format(x))
ascChr = []
for i in range(32, 128):
ascChr.append(chr(i))
data = [
0xBE, 0xEF, 0xDE, 0xAD
]
lines = (len(data)//16)
if len(data)%16 != 0:
lines += 1
i = 0
pr = ''
for x in range(lines):
pr += "{:000000008X}{:1}|{:1}".format(x*16,'','')
btes = []
symbs = []
for y in range(i,i+16,1):
if y >= len(data):
for x in range((lines*16)-y):
symbs.append(' ')
btes.append(' ')
break
if chr(data[y]) in ascChr:
symbs.append(chr(data[y]))
else:
symbs.append('∙')
btes.append(hxStr[data[y]])
i = y+1
for y in range(len(btes)):
pr += "{:3}".format(btes[y])
pr += '|{:1}'.format('')
for y in range(len(symbs)):
pr += "{:1}".format(symbs[y])
pr += '\r\n'
print("{:9}|{:1}0{:2}1{:2}2{:2}3{:2}4{:2}5{:2}6{:2}7{:2}8{:2}9{:2}A{:2}B{:2}C{:2}D{:2}E{:2}F{:2}|\
{:1}0123456789ABCDEF".format('Offset','','','','','','','','','','','','','','','','','','',''))
print(pr)