Python Interactive Interpreter always returns “Invalid syntax” on Windows

前端 未结 5 1583
迷失自我
迷失自我 2020-12-16 04:23

I\'ve encountered an extremely confusing problem. Whatever I type into the Python interpreter returns \"Invalid Syntax\". See examples below. I\'ve tried fooling around w

5条回答
  •  孤城傲影
    2020-12-16 05:15

    I face the same problem even though it might not the same like you, but there's alternative way to diagnostic, you should always set up a history file.

    I find out the reason by vim the history file (or you might consider hexdump -C in case vim doesn't shows the hidden characters):

    According to http://www.w3.org/International/questions/qa-bidi-controls :

    RLM and LRM characters

    Two other invisible but non-embedding directional control characters provided by Unicode do not usually have corresponding markup and should be used either in character or escaped form. Note that they are less problematic because they are used singly, not in pairs to delimit ranges of text like the other control characters we have discussed.

    U+200E:   LEFT-TO-RIGHT MARK
    U+200F:   RIGHT-TO-LEFT MARK
    

    The reason is because i direct copy/paste from online code(i know it's dangerous in security though) which contains hidden RLM and LRM characters.

提交回复
热议问题