简体   繁体   English

这是什么? (换行符后出现意外字符)

[英]what is this? (unexpected character after line continuation character)

for x in range(len(s.body)):
        if s.body[x].pos in list(map(lambda z:z.pos,s.body[x+1:])):
            print(\'Score: \', len(s.body))
            message_box(\'You Lost!\', \'Play again...\')
            s.reset((10,10))
            break 

It seems fine to me, but i cant seem to find the error.对我来说似乎很好,但我似乎无法找到错误。

The single quotation mark ' is written as \\' in your code (perhaps due to copying?) Simply run单引号'写为\\'在你的代码(可能是由于复制?)只需运行

for x in range(len(s.body)):
        if s.body[x].pos in list(map(lambda z:z.pos,s.body[x+1:])):
            print('Score: ', len(s.body))
            message_box('You Lost!', 'Play again...')
            s.reset((10,10))
            break 

\\ is the "line continuation character" in Python that continues a line to the next line, which is not expected here. \\是 Python 中的“行继续符”,它将一行延续到下一行,这在此处是不期望的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM