创新互联www.cdcxhl.cn八线动态BGP香港云服务器提供商,新人活动买多久送多久,划算不套路!
这篇文章主要介绍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字符串解码的方法的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联-成都网站建设公司行业资讯频道!