decode(): 從指定編碼方式解碼為unicode方式
eg: bytes.decode(encoding="utf-8", errors="strict")
encoding: 要使用的編碼errors: 設(shè)置不同錯(cuò)誤的處理方案。默認(rèn)為 'strict',意為編碼錯(cuò)誤引起一個(gè)UnicodeError。 其他可能得值有 'ignore', 'replace', 'xmlcharrefreplace', 'backslashreplace' 以及通過(guò) codecs.register_error() 注冊(cè)的任何值。
encode(): 從unicode編碼為指定編碼方式
eg: str.encode(encoding='UTF-8',errors='strict')
- 參數(shù)同上