Pythonでファイルコンテンツのエンコーディングを表示する方法

chardetを使用してファイルのテキストコンテンツのエンコーディング表示する

コード:

import chardet

currentFile = open('dev_msra.bmes',mode='rb')
content = currentFile.read()

print(chardet.detect(content))

注:Openは、オープンモードを「b」バイナリオープンとして指定する必要があり、「rb」または「wb」またはその他の組み合わせメソッドが必要です。「b」モードを使用するだけでは不十分です。

おすすめ

転載: blog.csdn.net/weixin_41297561/article/details/108659846