私信  •  关注

AMGMNPLK ZdaR

AMGMNPLK ZdaR 最近创建的主题
AMGMNPLK ZdaR 最近回复了

在Python 3.x中 raw_input() Python 2.x的 input() 功能。但是,在这两种情况下,您都不能输入多行字符串,为此,您需要逐行从用户处获取输入,然后 .join() 他们使用 \n ,或者也可以采用不同的行并使用 + 运算符分隔为

要从用户处获取多行输入,可以执行以下操作:

no_of_lines = 5
lines = ""
for i in xrange(no_of_lines):
    lines+=input()+"\n"

print(lines)

或者

lines = []
while True:
    line = input()
    if line:
        lines.append(line)
    else:
        break
text = '\n'.join(lines)