python - 为什么出现 EOL 错误以及它的含义是什么?

标签 python string string-literals eol

在扫描字符串文字时,它不断出现EOL,但这是什么意思?

这是它不断调用错误的部分:

if health2 <= 3:
  print ("With all the strength you have left you attack one final time to deliver the 
finishing blow. The zombie falls to the ground dead as you stand over it victorious. You can 
now continue your quest to cross the country.")

最佳答案

这意味着您的字符串文字格式错误。您需要对 multi-line string 使用三引号:

if health2 <= 3:
    print ("""With all the strength you have left you attack one final time to deliver 
the finishing blow. The zombie falls to the ground dead as you stand over it victorious. You 
can now continue your quest to cross the country.""")

仅用单引号括起来的字符串文字不能跨越多行。

关于python - 为什么出现 EOL 错误以及它的含义是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26473885/

相关文章:

c - 如何释放字符串文字消耗的内存?

python - 在 MacOS Catalina 升级后部署 Google Dataflow 模板时,Protobuf 的数据库错误中已存在文件

ios - 如何使用正则表达式删除字符串中间的新行

java - 递归查找字符串中最长的单词

objective-c - Objective-C 是否使用字符串池?

ruby - 艰难地学习 Ruby 第 9 章三重引号

python - 值在函数中正确打印,但返回时为 None

python - 您可以在 Keras 中编写自定义学习率调度程序吗?

python - 在 PyCharm CE 中使用 Selenium

java - 向控制台输出一行 90 个等号,两边有空行