python3.4 字符串转16进制

def str_to_hex(s):
    s = s.split(' ')
    send_buf = b''
    for i in range(len(s)):
        send_buf  += struct.pack('B',int(s[i],16))
    return(send_buf)

你可能感兴趣的:(python3.4 字符串转16进制)