pip install chardet python import chardet def detect_encoding(file_path): with open(file_path, 'rb') as f: raw_data = f.read() result = chardet.detect(raw_data) encoding = result['encoding'] confidence = result['confidence'] file_path = "example.txt" detect_encoding(file_path)


上一篇:
下一篇:
切换中文