python encode和decode的妙用
时间:2021-01-08 01:34:20
>>> "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 |
标签:python,encode,decode
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python 多线程应用介绍
2023-07-13 08:04:04
用js封装的时间设置器
2013-08-04 23:28:46
Python正则表达式匹配HTML页面编码
2023-07-29 06:50:36
详解Python使用OpenCV如何确定一个对象的方向
2022-04-06 04:16:42
![](https://img.aspxhome.com/file/2023/6/65966_0s.jpg)
为SQL Server数据库传数组参数的变通办法
2009-10-23 09:26:00
GoJs的文本绘图模板TextBlock使用实例
2023-08-26 16:01:00
![](https://img.aspxhome.com/file/2023/6/56246_0s.jpg)
Python第三方库face_recognition在windows上的安装过程
2023-07-27 02:51:29
Python实现方便使用的级联进度信息实例
2021-04-22 12:31:18
深入浅析Python 命令行模块 Click
2022-12-13 19:41:40
Python Django view 两种return的实现方式
2022-05-03 16:07:04
python3.6根据m3u8下载mp4视频
2021-05-22 00:20:03
![](https://img.aspxhome.com/file/2023/5/79795_0s.png)
AJAX在GET中文的时候解决乱码的方法
2007-11-04 13:04:00
在Typescript中如何使用for...in详解
2023-08-18 15:39:32
Flask 使用类组织配置详情
2023-06-15 02:31:30
![](https://img.aspxhome.com/file/2023/6/60716_0s.png)
FckEditor配置手册中文教程详细说明
2010-02-28 12:37:00
细化解析:SQL Server 2005 数据库镜像
2009-01-23 13:41:00
如何用python反转图片,视频
2023-08-27 08:18:21
![](https://img.aspxhome.com/file/2023/6/69596_0s.jpg)
比较一下看看自己掌握了多少SQL快捷键
2009-01-04 14:04:00
有关Oracle数据库的备份情况
2010-07-30 13:21:00
解决pycharm中opencv-python导入cv2后无法自动补全的问题(不用作任何文件上的修改)
2023-08-24 00:25:21
![](https://img.aspxhome.com/file/2023/5/61205_0s.jpg)