【问题标题】:What does EOL in python 3 mean? [closed]python 3中的EOL是什么意思? [关闭]
【发布时间】:2020-09-13 10:00:24
【问题描述】:

根据本站https://www.askpython.com/python/syntax-error-eol-while-scanning-string-literal,EOL特指“到达“行尾”,同时扫描是指到达最后字符串的字符并且没​​有遇到结束引号。”

但是在这个例子中,开头缺少引用,为什么它仍然会发生? 例子

>>> print(hello')
  
File "<stdin>", line 1
    print(hello')
                ^
SyntaxError: EOL while scanning string literal

【问题讨论】:

  • 它找到了一个报价,向前寻找另一个,但没有。它不知道您意味着引用是结束引用。

标签: python python-3.x string literals eol


【解决方案1】:

知道该行前面应该有一个 ',但 Python 没有。

Python 分词器看到 ',它以字符串文字开头。然后它会看到),然后是行尾。

【讨论】:

    猜你喜欢
    • 2014-03-08
    • 1970-01-01
    • 2018-08-30
    • 2018-01-24
    • 2010-12-29
    • 2014-09-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多