多行用户输入python [英] Multiline user input python

查看:88
本文介绍了多行用户输入python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何编写一个可以接受多行输入的简单程序,然后可以像在lynx浏览器中一样提交输入,在该浏览器中您可以使用空白行然后使用句点来提交输入.

I would like to know how to write a simple program that can accept multiple lines of input, then the input can be submitted like in the lynx browser, where you use a blank line and then a period to submit the input.

我想在电子邮件程序中使用它.

i want to use it in an email program.

推荐答案

这是一种简单的方法:

#!/usr/bin/python

input_list = []

while True:
    input_str = raw_input(">")
    if input_str == "." and input_list[-1] == "":
        break
    else:
        input_list.append(input_str)

for line in input_list:
    print line

这篇关于多行用户输入python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆