Lexical error: Encountered: “” (0), after : “”

前端 未结 1 1029
一个人的身影
一个人的身影 2021-01-21 01:14

I needed to start dealing with foreign characters, and in doing so, I think I royally screwed up a file\'s encoding.

The error I\'m getting is:

Lexical e         


        
相关标签:
1条回答
  • 2021-01-21 01:57

    If it is indeed a zero character in there, you may find you've injected some UTF-16/UCS-2 text. That particular Unicode encoding would have a zero byte in between every ASCII character.

    The best way to find out is to do a hex dump of you file with something like od -xcb myfile.py.

    If that is the case, then you'll need to edit the file with something that's able to see those characters, and fix them up.

    vi would be my first choice (since that's what I'm used to) but I don't want to start any holy wars with the Emacs illuminati. In vi, they'll most likely show up as ^@ characters.

    0 讨论(0)
提交回复
热议问题