12 lines
407 B
Python
12 lines
407 B
Python
import chardet
|
|
|
|
def detect_file_encoding(file_path):
|
|
with open(file_path, 'rb') as file:
|
|
raw_data = file.read()
|
|
result = chardet.detect(raw_data)
|
|
encoding = result['encoding']
|
|
confidence = result['confidence']
|
|
print(f"Detected encoding: {encoding}, Confidence: {confidence}")
|
|
|
|
file_path = r"C:\Users\zy187\Desktop\销售明细.csv"
|
|
detect_file_encoding(file_path) |