I read a printed byte in a file, as a string:
a = "b'\xa0-\xfc\xa3\xf8\xd9'"
type(a)
is str
.
How should I decode it?
The decoded value should be a02dfca3f8d9
.
A part the file is uploaded here: https://www.dropbox.com/s/p12pwwhknu3gr4h/info.log?dl=1
[PICA8-P3297] dl-dst output #1 OFPFlowMod(actions=[OFPActionOutput(max_len=65509,port=45)],buffer_id=4294967295,command=0,cookie=16895774056056650001,flags=0,hard_timeout=0,idle_timeout=0,match=OFPMatch(dl_dst=b'\xa0-\xfc\xa3\xf8\xd9',dl_src=b'\x00\x00\x00\x00\x00\x00',dl_type=0,dl_vlan=0,dl_vlan_pcp=0,in_port=0,nw_dst=0,nw_proto=0,nw_src=0,nw_tos=0,tp_dst=0,tp_src=0,wildcards=4194295),out_port=65535,priority=1)
I open and get the dl_dst
value in the file by this line:
dl_dst = fm_line.split('OFPMatch')[1].split(',')[0].split('=')[1]
dl_dst
is supposed to be a Mac Address. My question is how to convert it?
As suggested, I tried:
print(''.join(["{0:x}".format(ord(char)) for char in dl_dst[2:-1]]))
But the printed resuls is 275c5c7861302d5c5c7866635c5c7861335c5c7866385c5c78643927
, which is not what I expected.