去除(UTF-8)格式文本中的Bom

def trimFile(name):
    file = open(name,'rb')
    content = file.read(3)
    if content != '\xEF\xBB\xBF':
        return False
    content = file.read()
    file.close()
    file = open(name,'wb')
    file.write(content)
    file.close
    print 'convert ',name,' finish'
    return True

 

posted on 2012-12-12 17:35  呆头龙  阅读(252)  评论(0)    收藏  举报

点击这里给我发消息