2022
我们一起努力

Python中decode函数怎么用

在Python中使用decode函数的方法

decode:decode()函数的作用是指定的编码格式解码字符串。

decode()函数语法:

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

参数:

encoding:表示需要指定的编码。

errors:设置不同错误的处理方案。

decode()函数使用方法:

str = "hello world";

str = str.encode('base64','strict');

print "Encoded String: " + str;

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

输出结果为:

Encoded String: dGhpcyBpcyBzdHJpbmcgZXhhbXBsZS4uLi53b3chISE=

Decoded String: hello world

赞(0)
文章名称:《Python中decode函数怎么用》
文章链接:https://www.fzvps.com/91983.html
本站文章来源于互联网,如有侵权,请联系管理删除,本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。
图片版权归属各自创作者所有,图片水印出于防止被无耻之徒盗取劳动成果的目的。

评论 抢沙发

评论前必须登录!