【问题标题】:Python EOFerror in online "Zybooks" coding在线“Zybooks”编码中的 Python EOFerror
【发布时间】:2021-08-25 00:51:01
【问题描述】:
user_num = int(input('Enter integer:\n'))
print(user_num)
print(user_num, 'squared is', user_num * user_num)
print('And', user_num, 'cubed is', user_num * user_num * user_num, '!!')
user_num2 = int(input('Enter another integer:\n'))
print(user_num2)
print(user_num, '+', user_num2, 'is', user_num + user_num2)
print(user_num, '*', user_num2, 'is', user_num * user_num2)

我的目标是接收来自查看器的 2 个输入,第一个输入是正方形和立方体,在出现提示时接收第二个输入,然后将这两个输入相加并相乘。我收到了第 5 行的 EOFerror,上面写着:

Traceback (most recent call last):
  File "main.py", line 5, in <module>
    user_num2 = input('Enter another integer:\n')
EOFError: EOF when reading a line

但是,如果我在 VS 中运行相同的代码,它完全可以正常工作。我在他们的网站上为我的班级使用 Zybooks 集成编码区域...有人知道这个问题的原因/解决方案是什么吗?

Screenshot

这是整个作业页面:

https://i.stack.imgur.com/5e6EQ.png

【问题讨论】:

  • 你向它提供什么输入?您知道 Zybooks 如何准确地传递输入吗?顺便说一句,欢迎来到 Stack Overflow!如果需要提示,请查看tourHow to Ask
  • @wjandrea Zybooks 允许我只添加一个输入,但在说明中特别要求 2。它显示“输入程序输入”,我在其中输入了#4,就像他们在示例中使用的一样。但它没有第二个输入的位置......
  • 看起来问题出在 Zybooks,而不是 python。不确定是否有很多人知道 Zybooks 的逻辑是如何工作的......
  • @Thionine 我同意 rzlvmp,这更多是关于 Zybooks 的问题,而不是 Python。查看屏幕截图,不清楚您应该如何提供第二个输入。除非您可以在“输入程序输入”框中按 Enter 键?如果这不起作用,请询问您的教授。
  • @rzlvmp 我也是这么想的,因为我无法为第二个整数输入另一个输入...我一直试图弄清楚它很长时间,当它在 VS 中工作时非常沮丧但不是网站。感谢您的积极肯定哈哈

标签: python


【解决方案1】:

我刚刚想通了!我被这个卡住了一段时间,你必须为多个变量添加一个新行。希望这有帮助!

【讨论】:

  • 请添加更多详细信息以扩展您的答案,例如工作代码或文档引用。
猜你喜欢
  • 2022-10-20
  • 1970-01-01
  • 1970-01-01
  • 2022-11-24
  • 2019-05-13
  • 2023-03-24
  • 1970-01-01
  • 2012-05-03
  • 1970-01-01
相关资源
最近更新 更多