Multiline user input python

后端 未结 1 1163
故里飘歌
故里飘歌 2020-12-06 22:13

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 l

相关标签:
1条回答
  • 2020-12-06 22:27

    Here's a simple way:

    #!/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
    
    0 讨论(0)
提交回复
热议问题