chardet查看字符串的編碼(非常好用)


chardet不是python自帶的包需要手動安裝

chardet安裝命令(dos下):

         pip install chardet  

或: pip.exe install chardet  

案例:

>>> import chardet
>>> import urllib
>>> TestData=urllib.urlopen("http://www.baidu.com/").read()
>>> print chardet.detect(TestData)
{'confidence': 0.99, 'language': '', 'encoding': 'utf-8'}
>>>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM