手机
当前位置:查字典教程网 >脚本专栏 >python >python判断字符串编码的简单实现方法(使用chardet)
python判断字符串编码的简单实现方法(使用chardet)
摘要:本文实例讲述了python判断字符串编码的方法。分享给大家供大家参考,具体如下:安装chardet模块chardet文件夹放在/usr/li...

本文实例讲述了python判断字符串编码的方法。分享给大家供大家参考,具体如下:

安装chardet模块

chardet文件夹放在/usr/lib/python2.4/site-packages目录下

[root@sha-sso-data01 chardet]# python Python 2.4.3 (#1, Sep 21 2011, 19:55:41) [GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2 Type "help", "copyright", "credits" or "license" for more information.

>>> import chardet >>> chardet.detect("我") {'confidence': 0.505, 'encoding': 'utf-8'} >>>

希望本文所述对大家Python程序设计有所帮助。

【python判断字符串编码的简单实现方法(使用chardet)】相关文章:

python 中文字符串的处理实现代码

python读取注册表中值的方法

wxpython 最小化到托盘与欢迎图片的实现方法

python函数返回多个值的示例方法

wxpython中利用线程防止假死的实现方法

python复制文件代码实现

基于python的汉字转GBK码实现代码

Python列表推导式的使用方法

python中将阿拉伯数字转换成中文的实现代码

python 动态获取当前运行的类名和函数名的方法

精品推荐
分类导航