>> '68656c6c6f'.decode("hex") 'hello'查了一下手册,还有这些codec可用CodecAliasesOperand typePurposebase64_codecbas ;更新日期:2025/1/12.幽灵资源网,磁力链接,云盘下载,BT种子,CPU天梯,显卡天梯,UU加速器,阅读3.0,英雄联盟,怪物猎人,无损音乐网,无损音乐下载网站,无损音乐免费下载,320Kmp3下载,无损音乐免费下载网站,音画欣赏,无损音乐,抖音神曲,发烧大碟,车载歌曲,试音天碟,WMA,WAV+CUE,WAV整轨,FLAC分轨,DSD黑胶,HI-FI试音,SACD-ISO,4K高清,高清电影下载,Magnet,Torrent,BitTorrent,迅雷快传,SUB,SRT,ASS/SSA,SUP,RARBG,TLF字幕,BluRay,x265,x264,DTS-HD,WEBRip,10BIT,HDR,DDP5.1,WEB-DL,1080p高清电影下载,中国高清网,高清电影,720p,1080p,MKV,AVI,蓝光原盘,3D高清,电影下载">

python encode和decode的妙用

脚本专栏 发布日期:2025/1/12 浏览次数:1

正在浏览:python encode和decode的妙用

> "hello".encode("hex")
'68656c6c6f'

相应的还可以

> '68656c6c6f'.decode("hex")
'hello'

查了一下手册,还有这些codec可用

Codec

Aliases

Operand type

Purpose

base64_codec base64, base-64 byte string Convert operand to MIME base64 bz2_codec bz2 byte string Compress the operand using bz2 hex_codec hex byte string Convert operand to hexadecimal representation, with two digits per byte idna   Unicode string Implements RFC 3490. New in version 2.3. See also encodings.idna mbcs dbcs Unicode string Windows only: Encode operand according to the ANSI codepage (CP_ACP) palmos   Unicode string Encoding of PalmOS 3.5 punycode   Unicode string Implements RFC 3492. New in version 2.3. quopri_codec quopri, quoted-printable, quotedprintable byte string Convert operand to MIME quoted printable raw_unicode_escape   Unicode string Produce a string that is suitable as raw Unicode literal in python source code rot_13 rot13 Unicode string Returns the Caesar-cypher encryption of the operand string_escape   byte string Produce a string that is suitable as string literal in python source code undefined   any Raise an exception for all conversions. Can be used as the system encoding if no automatic coercion between byte and Unicode strings is desired. unicode_escape   Unicode string Produce a string that is suitable as Unicode literal in python source code unicode_internal   Unicode string Return the internal representation of the operand uu_codec uu byte string Convert the operand using uuencode zlib_codec zip, zlib byte string Compress the operand using gzip