目录

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

描述 (Description)

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

语法 (Syntax)

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

参数 (Parameters)

  • encoding - 这是要使用的编码。 有关所有编码方案的列表,请访问: 标准编码。

  • errors - 可以设置不同的错误处理方案。 错误的默认值是'strict',这意味着编码错误会引发UnicodeError。 其他可能的值是'ignore','replace','xmlcharrefreplace','backslashreplace'以及通过codecs.register_error()注册的任何其他名称。

返回值 (Return Value)

解码后的字符串。

例子 (Example)

#!/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')

结果 (Result)

Encoded String: dGhpcyBpcyBzdHJpbmcgZXhhbXBsZS4uLi53b3chISE=
Decoded String: this is string example....wow!!!
↑回到顶部↑
WIKI教程 @2018