PriceForecast/fix_bom_main_juxiting.py
2025-11-06 09:13:16 +08:00

19 lines
520 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 修复文件开头的BOM字符
import os
# 文件路径
file_path = 'd:\\code\\PriceForecast-svn\\main_juxiting.py'
# 读取文件(二进制模式)
with open(file_path, 'rb') as f:
content = f.read()
# 检查并移除BOM字符EF BB BF是UTF-8 BOM的字节序列
if content.startswith(b'\xef\xbb\xbf'):
content = content[3:]
# 写回文件
with open(file_path, 'wb') as f:
f.write(content)
print('BOM has been removed successfully!')
else:
print('No BOM found in the file.')