在 python 中输入多行字符串
Input a multiline string in python
我正在尝试创建一个简单的程序,输入单个多行输入并将其输出为 table。
输入:
a
b
c
我知道我可以在 python 2.7.5 中轻松完成此操作,方法是使用:
input_string = raw_input("> ").splitlines()
这会 return ['a', 'b', 'c']
然而在python3中,行:
input_string = input("> ").splitlines()
仅 returns ['a']
因此它只读取输入字符串的第一行。
python3 中有什么方法可以接受多行输入吗?谢谢。
试试吧。
aux = ''
'\n'.join(iter(input, aux))
我正在尝试创建一个简单的程序,输入单个多行输入并将其输出为 table。
输入:
a
b
c
我知道我可以在 python 2.7.5 中轻松完成此操作,方法是使用:
input_string = raw_input("> ").splitlines()
这会 return ['a', 'b', 'c']
然而在python3中,行:
input_string = input("> ").splitlines()
仅 returns ['a']
因此它只读取输入字符串的第一行。
python3 中有什么方法可以接受多行输入吗?谢谢。
试试吧。
aux = ''
'\n'.join(iter(input, aux))