python
import chardet
def detect_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("Detected encoding: ", encoding)
print("Confidence: ", confidence)
file_path = "example.txt"
detect_encoding(file_path)