时间:2021-05-23
>>> "hello".encode("hex")
'68656c6c6f'
相应的还可以
>>> '68656c6c6f'.decode("hex")
'hello'
查了一下手册,还有这些codec可用
Codec
Aliases
Operand type
Purpose
base64_codecbase64, base-64byte stringConvert operand to MIME base64bz2_codecbz2byte stringCompress the operand using bz2hex_codechexbyte stringConvert operand to hexadecimal representation, with two digits per byteidnaUnicode stringImplements RFC 3490. New in version 2.3. See also encodings.idnambcsdbcsUnicode stringWindows only: Encode operand according to the ANSI codepage (CP_ACP)palmosUnicode stringEncoding of PalmOS 3.5punycodeUnicode stringImplements RFC 3492. New in version 2.3.quopri_codecquopri, quoted-printable, quotedprintablebyte stringConvert operand to MIME quoted printableraw_unicode_escapeUnicode stringProduce a string that is suitable as raw Unicode literal in python source coderot_13rot13Unicode stringReturns the Caesar-cypher encryption of the operandstring_escapebyte stringProduce a string that is suitable as string literal in python source codeundefinedanyRaise an exception for all conversions. Can be used as the system encoding if no automatic coercion between byte and Unicode strings is desired.unicode_escapeUnicode stringProduce a string that is suitable as Unicode literal in python source codeunicode_internalUnicode stringReturn the internal representation of the operanduu_codecuubyte stringConvert the operand using uuencodezlib_codeczip, zlibbyte stringCompress the operand using gzip声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
比较模糊的是session_decode和session_encode:boolsession_decode(stringdata);session_decod
本文实例讲述了python实现中文输出的两种方法。分享给大家供大家参考。具体如下:方法一:用encode和decode如:importos.pathimport
首先,要明白encode()和decode()的区别encode()的作用是将Unicode编码的字符串转换为其他编码格式。例如:st1.encode("utf
从5.2版本开始,PHP原生提供json_encode()和json_decode()函数,前者用于编码,后者用于解码。1、json_encode()该函数主要
从5.2版本开始,PHP原生提供json_encode()和json_decode()函数,前者用于编码,后者用于解码。一、json_encode()该函数主要