新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python字符串怎么解碼?
python字符串解碼的方法:

站在用戶的角度思考問題,與客戶深入溝通,找到索縣網(wǎng)站設(shè)計與索縣網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:做網(wǎng)站、網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、空間域名、網(wǎng)絡(luò)空間、企業(yè)郵箱。業(yè)務(wù)覆蓋索縣地區(qū)。
python中可以使用decode()方法對字符串進行解碼。
python中可以使用encode()方法將字符串轉(zhuǎn)換為bytes類型,此過程稱為“編碼”。
decode() 方法用于將 bytes 類型的二進制數(shù)據(jù)轉(zhuǎn)換為 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')輸出結(jié)果如下:
Encoded String: dGhpcyBpcyBzdHJpbmcgZXhhbXBsZS4uLi53b3chISE=
Decoded String: this is string example....wow!!!
網(wǎng)站標題:創(chuàng)新互聯(lián)Python教程:python字符串怎么解碼?
分享URL:http://www.5511xx.com/article/codhods.html


咨詢
建站咨詢
