Python - 我需要一种进行多行输入的特定方法
Python - I need a specific way of making multi-line input
我需要在 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.
I need something that would ask user to enter text (multi-line text)
and when user Paste text (Ctrl + C) and he press Enter, program
needs to put whole text into a list.
P.S。请不要将此标记为重复,因为它与其他对我没有帮助的问题有点不同。
尝试使用 while 循环:
listed = []
inputs = None
while inputs != '':
inputs = input()
listed.append(inputs)
listed = [i for i in listed if i != '']
print listed
我需要在 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.
I need something that would ask user to enter text (multi-line text) and when user Paste text (Ctrl + C) and he press Enter, program needs to put whole text into a list.
P.S。请不要将此标记为重复,因为它与其他对我没有帮助的问题有点不同。
尝试使用 while 循环:
listed = []
inputs = None
while inputs != '':
inputs = input()
listed.append(inputs)
listed = [i for i in listed if i != '']
print listed