Skip to content

Instantly share code, notes, and snippets.

@DeronW
Created May 30, 2013 01:05
Show Gist options
  • Save DeronW/5675123 to your computer and use it in GitHub Desktop.
Save DeronW/5675123 to your computer and use it in GitHub Desktop.
去掉文件的BOM头
import codecs
import os
includes = ['*.php', '*.html', '*.htm']
for root, dirs, files in os.walk('pay.lvye.cn'):
for filename in files:
filename = os.path.join(root, filename)
with open(filename) as f:
content = f.read()
if content[:3] == codecs.BOM_UTF8:
content = content[3:]
print filename
f.write(content)
f.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment