English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
1.实测,这个版本在32位window7和python3.2环境下正常使用。
2. Usage: Copy the chardet and docs folders after unpacking to the Lib\site-packages directory under the python3.2 directory to use normally.
3. The reference code for judging file encoding is as follows:
file = open(fileName, "rb")#You need to have "rb", otherwise the default uses gbk to read the file. buf = file.read() result = chardet.detect(buf) file = open(fileName,"r",encoding=result["encoding"]) content = file.readlines()
This article on 'chardet (instance explanation) for file encoding judgment in Python' is all the editor shares with everyone, hoping to provide a reference for everyone, and also hope that everyone will support the呐喊 tutorial more.
Declaration: The content of this article is from the network, the copyright belongs to the original author, the content is contributed and uploaded by Internet users spontaneously, this website does not own the copyright, does not undergo manual editing, nor assume relevant legal liability. If you find any content suspected of copyright infringement, please send an email to: notice#oldtoolbag.com (when sending an email, please replace # with @) to report it, and provide relevant evidence. Once confirmed, this site will immediately delete the suspected infringing content.