説明: 各文字をバイトに変換しord
、2 桁の 16 進数としてフォーマットし、それをリストにフィードします。次に、区切り文字としてスペースを使用してリストを結合します。
>>> ll = ["%02X" % (ord(x)) for x in '\x02S20390908127F010102F3004000900300000000000000000000000000000300A500000000000202020202020206070505050505050000000707070707070707020700000000000000000000000000000000000000008000800089237A0715047E000000000000000000000000000000000000000000000000000000000000000000000000005350374646303030\x1732']
>>> ll #as a list
['02', '53', '32', '30', '33', '39', '30', '39', '30', '38', '31', '32', '37', '46', '30', '31', '30', '31', '30', '32', '46', '33', '30', '30', '34', '30', '30', '30', '39', '30', '30', '33', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '33', '30', '30', '41', '35', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '32', '30', '32', '30', '32', '30', '32', '30', '32', '30', '32', '30', '32', '30', '36', '30', '37', '30', '35', '30', '35', '30', '35', '30', '35', '30', '35', '30', '35', '30', '30', '30', '30', '30', '30', '30', '37', '30', '37', '30', '37', '30', '37', '30', '37', '30', '37', '30', '37', '30', '37', '30', '32', '30', '37', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '38', '30', '30', '30', '38', '30', '30', '30', '38', '39', '32', '33', '37', '41', '30', '37', '31', '35', '30', '34', '37', '45', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '30', '35', '33', '35', '30', '33', '37', '34', '36', '34', '36', '33', '30', '33', '30', '33', '30', '17', '33', '32']
>>> ' '.join(ll) # as a string
'02 53 32 30 33 39 30 39 30 38 31 32 37 46 30 31 30 31 30 32 46 33 30 30 34 30 30 30 39 30 30 33 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 33 30 30 41 35 30 30 30 30 30 30 30 30 30 30 30 32 30 32 30 32 30 32 30 32 30 32 30 32 30 36 30 37 30 35 30 35 30 35 30 35 30 35 30 35 30 30 30 30 30 30 30 37 30 37 30 37 30 37 30 37 30 37 30 37 30 37 30 32 30 37 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 38 30 30 30 38 30 30 30 38 39 32 33 37 41 30 37 31 35 30 34 37 45 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 35 33 35 30 33 37 34 36 34 36 33 30 33 30 33 30 17 33 32'