Home > Article > Backend Development > How to input multiple lines in python
How to input multiple lines in python?
By default, Python ends input when encountering a carriage return. So we need to change this prompt
Set stopword="xxx"
stopword = ''#修改输入终止符为空行 str = '' print('请输入内容【单独输入‘‘保存退出】:') for line in iter(input,stopword): str+=line print(str)
Result:
Isn’t it very simple
Recommended "Python Tutorial"
The above is the detailed content of How to input multiple lines in python. For more information, please follow other related articles on the PHP Chinese website!