1. 程式人生 > >python 檢測字符串編碼類型是什麽

python 檢測字符串編碼類型是什麽

sci for decode value char chardet 檢測 asc dex

        for index,value in enumerate(listvalue):
            adchar=chardet.detect(value)
            print adchar
            if adchar[‘encoding‘]==‘utf-8‘ or adchar[‘encoding‘]==‘ascii‘:
                code=‘utf-8‘
            else:
                code=‘GBK‘
            value=value.decode(code)#解碼生成unicode編碼

  

python 檢測字符串編碼類型是什麽