Home  >  Article  >  Backend Development  >  How to input multiple lines in python

How to input multiple lines in python

藏色散人
藏色散人Original
2019-10-14 11:04:149557browse

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:

How to input multiple lines in python

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to delete pythonNext article:How to delete python