python encode和decode的妙用
发布时间:2021-01-08 01:34:20
标签: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 |


猜你喜欢
- 本文实例讲述了thinkPHP实现MemCache分布式缓存功能。分享给大家供大家参考,具体如下:两天在研究MemCache分布式缓存的问题
- 首先关键一句话:$(".js-example-tags").select2({ tags:
- 本文实例讲述了Python简单生成随机姓名的方法。分享给大家供大家参考,具体如下:用到random.choice(序列)在一个序列中随机选取
- 本次分析基于 CPython 解释器,python3.x版本在python2时代,整型有 int 类型和 long 长整型,长整型不存在溢出
- 这段时间告诉项目需要,用到了vue。刚开始搭框架的时候用的是vue-resource后面看到官方推荐axios就换过来了 顺便封装了一下 /
- replace(param1,param2,param3)param1 正则表达式;param2 将匹配的字符替换成指定字符;param3
- 用了一段时间的 typescript 之后,深感中大型项目中 typescript 的必要性,它能够提前在编译期避免许多 bug,如很恶心的
- 本文实例介绍了如何使用ASP代码来读写注册表,呵呵厉害吧! 一个例子: <%Dim ReadComputerNam
- 由于实际需要,简要写了个小脚本,并打包生成exe,供无网络环境下使用脚本1:显示当前时间与时间戳,以及10分钟后的时间与时间戳# -*- c
- 在Vista IIS 7 中用 vs2005 调试 Web 项目核心是要解决以下几个问题:1、Vista 自身在安全性方面的User Acc
- 海豚本文例子主要展示了如何使用补丁、路径和转换类绘制和操作给定的顶点和节点的形状。测试可用。import matplotlib.cm as
- python自定义异常实例详解 本文通过两种
- 以下几种方法来模拟enum:(感觉方法一简单实用)# way1class Directions: up
- 做前端也有几年时间了,不敢说能把他看地多透,但是多多少少还是有些自己的东西。下面以 Tudou.com 的首页为例,总结总结。就制作而言,我
- Javascript中括号有四种语义语义1,声明数组 var ary = []; // 声明一个空数组var ary = [1,3]; //
- 今天项目上遇到一个问题,需要在点击a标签时,将完整的内容显示出来原先是想用jquery的click方法<a ownattr=“……”
- 用简单的方法生成随机性较大的密码仅用20行代码随机生成密码核心思路:利用random模块random模块随机生成数字,大小写字母,循环次数w
- ExtJS可以用来开发RIA也即富客户端的AJAX应用,是一个用javascript写 的,主要用于创建前端用户界面,是一个与后台技术无关的
- 本文介绍了使用XMlhttp技术来生成html页面,值得借鉴。相关函数:<% ’定义xmlhttp funct
- 如何使整个页面内容居中,如何使高度适应内容自动伸缩。这是学习CSS布局最常见的问题。下面就给出一个实际的例子,并详细解释。(本文的经验和是蓝