Archive

How to Read Multi-line Input from Command Line Interface CLI

Recently, I ran into a problem where I needed to accept multiple lines from the clipboard to a Python CLI.

Here is the solution:

This function will return a list of lines that you can join up with newline chars or a separator of your choice.

 

def getInputLines():
    buff = []
    while  True:
        line = (raw_input())
        if not line: break
buff.append(line)
return buff