bytes方法 我怎樣才能把字節(jié)轉(zhuǎn)換成Python中的字符串?
我怎樣才能把字節(jié)轉(zhuǎn)換成Python中的字符串?#bytes object b=b “example ”#str object s=“example ”#str to bytes bytes(s,enc
我怎樣才能把字節(jié)轉(zhuǎn)換成Python中的字符串?
#bytes object b=b “example ”#str object s=“example ”#str to bytes bytes(s,encoding=“utf8”)#bytes to str str(b,encoding=“utf-8”)#另一種方法#str to bytesstr.encode編碼(s) #字節(jié)到字符串字節(jié).解碼(b)
了解python中bytes,str和unicode的區(qū)別?
STR是一個編碼字符串,如Unicode、GB2312、ASCII編碼,可以表示不同語言的字符,可以解碼成字節(jié)。Byte是一個字節(jié),只能是ASCII碼為0-255的字符,表示原始字符串而不進(jìn)行編碼