python如何判断字符串编码方式

python判断字符串编码方式的方法:1、打开命令提示符,进入python27\Script目录;2、执行命令安装chardet;3、判断字符串编码方式即可,如:【chardet.detect(f.read())】。

python如何判断字符串编码方式

具体方法:

(推荐教程:python入门教程)

1、安装chardet

在命令行中,进入python27\Scripts目录,执行以下命令

easy_installchardet

2、判断方法

importchardet
f=open('file','r')
fencoding=chardet.detect(f.read())
printfencoding