Python


编码

<p>Python decode()方法 Python 字符串 Python 字符串</p> <p>描述 Python decode() 方法以 encoding 指定的编码格式解码字符串。默认编码为字符串编码。</p> <p>语法 decode()方法语法:</p> <p>str.decode(encoding='UTF-8',errors='strict') 参数 encoding -- 要使用的编码,如&quot;UTF-8&quot;。</p> <p>errors -- 设置不同错误的处理方案。默认为 'strict',意为编码错误引起一个UnicodeError。 其他可能得值有 'ignore', 'replace', 'xmlcharrefreplace', 'backslashreplace' 以及通过 codecs.register_error() 注册的任何值。</p> <p>返回值 该方法返回解码后的字符串。</p> <p>实例 以下实例展示了decode()方法的实例:</p> <p>实例(Python 3.0+)</p> <h1>!/usr/bin/python</h1> <p>str = &quot;this is string example....wow!!!&quot;; str = str.encode('base64','strict');</p> <p>print &quot;Encoded String: &quot; + str; print &quot;Decoded String: &quot; + str.decode('base64','strict')</p> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=b8260638ac87f4b8563ea212d17d4ca6" alt="" /></p> <p>以上实例输出结果如下:</p> <p>Encoded String: dGhpcyBpcyBzdHJpbmcgZXhhbXBsZS4uLi53b3chISE=</p> <p>Decoded String: this is string example....wow!!!</p>

页面列表

ITEM_HTML