python3 字符串 16进制 相互转换

    技术2022-07-20  70

    def str_to_hex(s): """ 字符串 转 16进制 :param s: :return: """ return ' '.join([c.encode().hex() for c in s])

     

    def hex_to_str(s): """ 16进制转 str :param s: :return: """ return bytes.fromhex(s).decode()
    Processed: 0.008, SQL: 9