修复bug
This commit is contained in:
25
fix_boms.py
Normal file
25
fix_boms.py
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
import os
|
||||
|
||||
def fix_bom(directory):
|
||||
count = 0
|
||||
for root, dirs, files in os.walk(directory):
|
||||
for file in files:
|
||||
if file.endswith('.uvue') or file.endswith('.uts') or file.endswith('.json'):
|
||||
filepath = os.path.join(root, file)
|
||||
try:
|
||||
with open(filepath, 'rb') as f:
|
||||
raw = f.read()
|
||||
|
||||
if raw.startswith(b'\xef\xbb\xbf'):
|
||||
# Remove BOM
|
||||
new_content = raw[3:]
|
||||
with open(filepath, 'wb') as f:
|
||||
f.write(new_content)
|
||||
print(f"Fixed BOM: {filepath}")
|
||||
count += 1
|
||||
except Exception as e:
|
||||
pass
|
||||
return count
|
||||
|
||||
print(f"Total files fixed: {fix_bom(r'd:\骅锋\mall')}")
|
||||
Reference in New Issue
Block a user