import binascii
datastr='13'
#string 類型轉換為byte
dataByte=str.encode(datastr)
#byte串 轉換為16進制 byte串 ,比如 b'12' 轉換為b'3132'
a=binascii.b2a_hex(dataByte)
#16 進制byte串 轉換為string串,比如b'3132' 轉換為"3132",用來顯示
print(a.decode())
#16 進制string 轉換為byte串,比如'1112' 轉換為b"\x11\x12",用來傳輸
print(bytes.fromhex("1112"))