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編碼