Python decode()方法

描述

Python decode() 方法以 encoding 指定的编码格式解码字符串。默认编码为字符串编码。

语法

decode()方法语法:string.decode(encoding='UTF-8',errors='strict')

参数encoding -- 要使用的编码,如"UTF-8"。

errors -- 设置不同错误的处理方案。默认为 'strict',意为编码错误引起一个UnicodeError。 其他可能得值有 'ignore', 'replace', 'xmlcharrefreplace', 'backslashreplace' 以及通过 codecs.register_error() 注册的任何值。

返回值

该方法返回解码后的字符串。

实例

以下实例展示了decode()方法的实例:#!/usr/bin/python

string = "this is string example....wow!!!"

string = string.encode('base64','strict')

print "Encoded String: " + string

print "Decoded String: " + string.decode('base64','strict')

以上实例输出结果如下:Encoded String: dGhpcyBpcyBzdHJpbmcgZXhhbXBsZS4uLi53b3chISE=

Decoded String: this is string example....wow!!!

python decode ignore_Python decode()方法 - Python 教程 - 自强学堂相关推荐

  1. python查看指令的方法python -h

    python查看指令的方法python -h 进入cmd 输入 python -h C:\Users\Administrator>python -h usage: python [option] ...

  2. python json安装_Python JSON - Python 基础教程 - 自强学堂

    Python JSON 本章节我们将为大家介绍如何使用 Python 语言来编码和解码 JSON 对象. Python 2.7 自带 JSON 模块[官方文档] 1. 从python原始类型向json ...

  3. python charm下载安装教程-Python及Pycharm安装方法图文教程

    Python及Pycharm安装方法,供大家参考,具体内容如下 1.任务简介 为了学习Python我今天对它进行了安装,整个安装过程忘了截图,故我在虚拟机中重新安装了一遍,并将Python及Pycha ...

  4. python读取word的方法,Python读取Word(.docx)正文信息的方法

    Python读取Word(.docx)正文信息的方法 本文介绍用Python简单读取*.docx文件信息,一些python-word库就是对这种方法的扩展. 介绍分两部分: Word(*.docx)文 ...

  5. python selenium定位元素方法,python + selenium 练习篇 - 定位元素的方法

    1.利用ID定位元素(能直接通过ID来定位的元素比较少) # coding=utf-8 from selenium import webdriver driver = webdriver.Chrome ...

  6. Python Gitlab Api 使用方法 - python

    文章来源:嗨学网 敏而好学论坛www.piaodoo.com 欢迎大家相互学习 简述 公司使用gitlab 来托管代码,日常代码merge request 以及其他管理是交给测试,鉴于操作需经常打开网 ...

  7. python maketrans_Python maketrans()方法 - Python 教程 - 自强学堂

    Python maketrans()方法 描述 Python maketrans() 方法用于创建字符映射的转换表,对于接受两个参数的最简单的调用方式,第一个参数是字符串,表示需要转换的字符,第二个参 ...

  8. python endwith_Python endswith()方法 - Python 教程 - 自强学堂

    Python endswith()方法 描述 Python endswith() 方法用于判断字符串是否以指定后缀结尾,如果以指定后缀结尾返回True,否则返回False.可选参数"star ...

  9. python endswith_Python endswith()方法 - Python 教程 - 自强学堂

    Python endswith()方法 描述 Python endswith() 方法用于判断字符串是否以指定后缀结尾,如果以指定后缀结尾返回True,否则返回False.可选参数"star ...

最新文章

  1. JMeter打开脚本报错处理方法
  2. Linux(Centos)之安装Java JDK及注意事项
  3. Spring NamedParameterJdbcTemplate 详解
  4. java中数组属于哪种类型_在Java中,关于数组描述正确的是
  5. Redis笔记(六):Java中使用Redis
  6. 云主机初体验(盛大云和阿里云)
  7. struts codenips
  8. ASP.NET 例程完全代码版(5)——通过web.config配置数据库连接池
  9. 全面支持开源,微软加速 Visual Studio 和 Azure DevOps 云升级
  10. 华为在中国建立其全球最大的网络安全透明中心
  11. web标准三个要素 此标准的好处
  12. 人类首张黑洞照片发布,像甜圈圈,顺便恭喜爱因斯坦
  13. mysql批量插入之提高插入效率
  14. 在Linux下基于路由策略的IP地址控制
  15. ipq_read(3)
  16. OSChina 周六乱弹 ——程序员想让对象一辈子跟你的秘籍
  17. 网刻工具大全:四款软件优缺评析(转)
  18. 大学计算机学术活动,计算机学院学术活动公告---南京理工大学Wai-Tat Fu教授学术报告...
  19. 424. Longest Repeating Character Replacement
  20. html表单验证邮箱表达式,Javascript正则表达式实现表单验证

热门文章

  1. Layui编辑页面的数据回显
  2. tableau学习案例
  3. Linux发行版在嵌入式设备上的未来
  4. android打开视频噔_Android中三种视频的播放
  5. LeetCode-79. 单词搜索
  6. 剑指offer-8 跳台阶
  7. 吞食天地我方加入武将一览
  8. 数据结构栈的创建(c语言)
  9. 【词性的选择与所放位置练习题】but vs however
  10. 笔记本电脑进水后的正确处理方法