UTF-8 HTML and CSS files with BOM (and how to remove the BOM with Python)

前端 未结 4 742
失恋的感觉
失恋的感觉 2020-12-03 21:41

First, some background: I\'m developing a web application using Python. All of my (text) files are currently stored in UTF-8 with the BOM. This includes all my HTML template

4条回答
  •  我在风中等你
    2020-12-03 22:24

    Check the first character after decoding to see if it's the BOM:

    if u.startswith(u'\ufeff'):
      u = u[1:]
    

提交回复
热议问题