提问人:HJ-1549 提问时间:7/14/2023 更新时间:7/14/2023 访问量:12
在连续输入过程中按 Cmd-D 时如何停止 ^D 的自动打印?
How can I stop the auto-printing of ^D when pressing Cmd-D during continuous input?
问:
我正在尝试多次请求输入并不断请求输入,直到按 Cmd-D 触发 EOF。现在我正在这样做
while True:
try:
number = input("number: ")
except EOFError:
break
else:
# apply operations to foo (example: multiply number 2)
假设我在 Cmd-D 之前键入 5 和 6,这是输出。 数量: 5 数量: 6 ^D 10 12
出于某种原因,它会自动在终端上打印 ^D,即使我没有打印任何额外的内容。我期望它没有“^D”。 我怎样才能阻止这种情况的发生?
答: 暂无答案
评论