【发布时间】:2015-02-08 15:41:47
【问题描述】:
我需要在 Python 中进行多行输入。 这是我的程序的一部分:
input_ = input("Enter text:\n") #This can handle only single line of text
像这样:
Enter text:
This is frst line, #Variable input_ would be only this line
this is second line,
this is last line.
我需要一些要求用户输入文本的东西(多行文本) 当用户粘贴文本(Ctrl + C)并按Enter键时,程序 需要将整个文本放入列表中。
附:请不要将此标记为重复,因为它与其他对我没有帮助的问题有点不同。
【问题讨论】:
-
如何知道输入何时结束?
-
当用户按下 Enter 时输入结束。
-
在多行输入中,每行后面都有一个换行符(回车)。您如何将其与“用户输入的输入结束输入”区分开来?
-
用户需要粘贴文本,一旦按下输入就结束了。
-
在安特下面看我的回答。用户可以粘贴然后回车。
标签: python text input line break