中文字幕一区二区人妻电影,亚洲av无码一区二区乱子伦as ,亚洲精品无码永久在线观看,亚洲成aⅴ人片久青草影院按摩,亚洲黑人巨大videos

Python decode()方法

Python 字符串 Python 字符串


描述

Python decode() 方法以 encoding 指定的編碼格式解碼字符串。默認(rèn)編碼為字符串編碼。

語法

decode()方法語法:

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

參數(shù)

  • encoding -- 要使用的編碼,如"UTF-8"。

  • errors -- 設(shè)置不同錯誤的處理方案。默認(rèn)為 'strict',意為編碼錯誤引起一個UnicodeError。 其他可能得值有 'ignore', 'replace', 'xmlcharrefreplace', 'backslashreplace' 以及通過 codecs.register_error() 注冊的任何值。

返回值

該方法返回解碼后的字符串。

實(shí)例

以下實(shí)例展示了decode()方法的實(shí)例:

實(shí)例(Python 3.0+)

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

以上實(shí)例輸出結(jié)果如下:

Encoded String: dGhpcyBpcyBzdHJpbmcgZXhhbXBsZS4uLi53b3chISE=

Decoded String: this is string example....wow!!!

Python 字符串 Python 字符串

其他擴(kuò)展