• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > 简单介绍Python中的decode()方法的使用

简单介绍Python中的decode()方法的使用

作者:goldensun 字体:[增加 减小] 来源:互联网

goldensun 通过本文主要向大家介绍了python decode,python decode函数,python decode encode,python3 decode,python中decode等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

 decode()方法使用注册编码的编解码器的字符串进行解码。它默认为默认的字符串编码。
语法

以下是decode()方法的语法:

str.decode(encoding='UTF-8',errors='strict')

</div>

参数

  •     encoding -- 这是所使用的编码。对于所有的编码方案的列表,请访问:标准编码库
  •     errors -- 这可能是给定一个不同的错误处理机制。默认的错误是“严格”,即编码错误提出UnicodeError。其他可能的值是ignore', 'replace', 'xmlcharrefreplace', 'backslashreplace' 并通过codecs.register_error().注册的任何其他名称。

返回值

此方法返回的字符串的解码版本。
例子

下面的例子显示了decode()方法的使用。

#!/usr/bin/python

str = "this is string example....wow!!!";
str = str.encode('base64','strict');

print "Encoded String: " + str;
print "Decoded String: " + str.decode('base64','strict')

</div>

当我们运行上面的程序,它会产生以下结果:

Encoded String: dGhpcyBpcyBzdHJpbmcgZXhhbXBsZS4uLi53b3chISE=

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

</div>


</div>

您可能想查找下面的文章:

  • Python中encode()方法的使用简介
  • 简单介绍Python中的decode()方法的使用
  • python实现颜色rgb和hex相互转换的函数
  • python encode和decode的妙用
  • Python字符串的encode与decode研究心得乱码问题解决方法

相关文章

  • Python实现从URL地址提取文件名的方法
  • python计算最小优先级队列代码分享
  • Python内置的字符串处理函数整理
  • 在Python中操作字典之setdefault()方法的使用
  • python实现斐波那契递归函数的方法
  • Python与Java间Socket通信实例代码
  • python optparse模块使用实例
  • 详解Django通用视图中的函数包装
  • python连接oracle数据库实例
  • Python文件去除注释的方法

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • 布同 Python中文问题解决方法(总结了多位前人经验,初学者必看)
    • python统计文本文件内单词数量的方法
    • Python 中 list 的各项操作技巧
    • Python过滤列表用法实例分析
    • 举例讲解Django中数据模型访问外键值的方法
    • Python Socket编程入门教程
    • Python Socket编程详细介绍
    • python实现数组插入新元素的方法
    • 利用matplotlib+numpy绘制多种绘图的方法实例
    • 跟老齐学Python之重回函数

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有