Python decode()方法
描述
Python decode() 方法以 encoding 指定的编码格式解码字符串。默认编码为字符串编码。
语法
decode()方法语法:
str.decode(encoding=‘UTF-8’,errors=‘strict’)
参数
encoding -- 要使用的编码,如"UTF-8"。errors -- 设置不同错误的处理方案。默认为 'strict',意为编码错误引起一个UnicodeError。 其他可能得值有 'ignore', 'replace', 'xmlcharrefreplace', 'backslashreplace' 以及通过 codecs.register_error() 注册的任何值。
返回值
该方法返回解码后的字符串。
实例
以下实例展示了decode()方法的实例:
实例(Python 3.0+)
#!/usr/bin/pythonstr = "this is string example....wow!!!";
str = str.encode('base64','strict');print "Encoded String: " + str;
print "Decoded String: " + str.decode('base64','strict')
以上实例输出结果如下:
Encoded String: dGhpcyBpcyBzdHJpbmcgZXhhbXBsZS4uLi53b3chISE=Decoded String: this is string example....wow!!!
Python decode()方法相关推荐
- python decode方法_Python中decode()方法有哪些功能?
摘要: 下文讲述Python中decode()的方法的功能简介说明,如下所示: decode()方法功能: 使用指定编码格式对bytes对象进行解码, 缺省编码格式为"utf-8" ...
- python中decode的用法_python中list怎么使用decode方法设置编码
Python decode() 方法以 encoding 指定的编码格式解码字符串.默认编码为字符串编码. decode()方法语法:str.decode(encoding='UTF-8',error ...
- python decode ignore_Python decode()方法 - Python 教程 - 自强学堂
Python decode()方法 描述 Python decode() 方法以 encoding 指定的编码格式解码字符串.默认编码为字符串编码. 语法 decode()方法语法:string.de ...
- python str字符串和byte字节流的区别 encode、decode方法的区别
Python 3最重要的新特性之一是对字符串和二进制数据流做了明确的区分.文本总是Unicode,由str类型表示,二进制数据则由bytes类型表示.Python 3不会以任意隐式的方式混用str和b ...
- python bytes decode_Python3 bytes.decode()方法
Python3 bytes.decode()方法 发布时间:2019-10-30 点击:46 Python3 bytes.decode()方法 功能: bytes.decode() 方法以指定的编码格 ...
- Python 字符串方法详解
Python 字符串方法详解 本文最初发表于赖勇浩(恋花蝶)的博客(http://blog.csdn.net/lanphaday),如蒙转载,敬请保留全文完整,切勿去除本声明和作者信息. 在编程中,几 ...
- pythonunicode和str_python的str,unicode对象的encode和decode方法
python的str,unicode对象的encode和decode方法 python中的str对象其实就是"8-bit string" ,字节字符串,本质上类似java中的byt ...
- [转载] python字符串方法有哪些_27种Python字符串操作方法大全
参考链接: Python字符串方法3| strip,lstrip,rstrip,min,max,maketrans,translate,replace和expandtabs 1.去空格及特殊符号 代码 ...
- Python ljust()方法
描述 Python ljust() 方法返回一个原字符串左对齐,并使用空格填充至指定长度的新字符串.如果指定的长度小于原字符串的长度则返回原字符串. 语法 ljust()方法语法: str.ljust ...
最新文章
- 安卓app和iosapp开发有什么不同呢?-综合外链_想让卫星软件不“软” 给草根开发者提供的条件得“硬”...
- SpringMVC中使用作用域对象完成数据的流转
- 常见的清除浮动的五种解决办法
- 初中计算机硬件家族教案,初一信息技术教案-探究计算机的硬件组成.docx
- matlab常数编程,用MATLAB编程序,拟合方程,求常数。 - 计算模拟 - 小木虫 - 学术 科研 互动社区...
- java8 内部类_Java8基础知识(五)内部类
- JVM实战总结:一个多线程中对象引用的问题
- JVM为什么需要GC
- Hadoop2.0环境搭建
- 64位ODBC数据源配置
- acp cp linux命令,系统运维
- vscode下载太慢,快速下载vscode方法!
- H5 可视化构建工具原理解析(一)
- Docker整理篇(docker-compose与私服搭建)
- 频谱分析系列:1dB增益压缩点概述及测试
- 论文翻译:Semantics-Guided Neural Networks for Efficient Skeleton-Based Human Action Recognition
- 01.14第65期短中线黑马推荐!
- tp剩余未验证内容-4
- 电子商业承兑汇票到期怎么兑现
- 源码编译mysql报错解决