python

#テキストファイルのBOMの有無を調べる
def has_bom(file_path):
    with open(file_path, 'rb') as f:
        first_bytes = f.read(3)
        return first_bytes == b'\xef\xbb\xbf'

file_path = 'base64-24-03-25.txt'
if has_bom(file_path):
    print(f'{file_path} contains BOM')
else:
    print(f'{file_path} does not contain BOM')