创新互联Python教程:python字符串怎么解码?
python字符串解码的方法:

站在用户的角度思考问题,与客户深入沟通,找到索县网站设计与索县网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:做网站、网站建设、企业官网、英文网站、手机端网站、网站推广、空间域名、网络空间、企业邮箱。业务覆盖索县地区。
python中可以使用decode()方法对字符串进行解码。
python中可以使用encode()方法将字符串转换为bytes类型,此过程称为“编码”。
decode() 方法用于将 bytes 类型的二进制数据转换为 str 类型,这个过程也称为“解码”。
decode() 方法的语法格式如下:
bytes.decode([encoding="utf-8"][,errors="strict"])
示例:
#!/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')输出结果如下:
Encoded String: dGhpcyBpcyBzdHJpbmcgZXhhbXBsZS4uLi53b3chISE=
Decoded String: this is string example....wow!!!
当前名称:创新互联Python教程:python字符串怎么解码?
地址分享:http://www.jxjierui.cn/article/codhods.html


咨询
建站咨询
