循环通过无限的多行输入
想象无限
您将如何分别从输入中获得该地址?
接近,但实际上没有帮助:
lines = []
while True:
line = input()
if line:
lines.append(line)
else:
break
text = '\n'.join(lines)
和其他建议我完全没有用: https://python.plainenglish.io/taking-multiple-inputs-from-user-in-python-3-6cbe02d03a95
Imagine unlimited multiline input with some URL addresses, for example:
How would you get that addresses from the input separately?
Following was close, but actually not helping:
lines = []
while True:
line = input()
if line:
lines.append(line)
else:
break
text = '\n'.join(lines)
source: How to get multiline input from user
And other advices I consider completely useless: https://python.plainenglish.io/taking-multiple-inputs-from-user-in-python-3-6cbe02d03a95
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我正确理解问题,这可能会有所帮助:
这将处理交互式和重定向输入(STDIN)
If I understand the problem correctly, this may help:
This will handle both interactive and redirected input (stdin)
您可以使用一个函数:
但是我不确定这是一个好主意,因为它不知道何时停止阅读。传统
input()
函数将通过返回键检测\ n
符号,然后结束输入。我认为循环是前进的最佳方法。
喜欢:
祝你有美好的一天。
There is a function you could use:
But I'm not sure this is a great idea because it won't know when to stop reading. The traditional
input()
function will detect a\n
symbol via the return key, then end input.I think looping would be the best way forward.
Like:
Have a nice day.