def standard_input ( ) : with click . get_text_stream ( "stdin" ) as stdin : while stdin . readable ( ) : line = stdin . readline ( ) if line : yield line . strip ( ) . encode ( "utf-8" )
how to take input from stdin in python
Generator that yields lines from standard input .
def standard_input():
    """Generator that yields lines from standard input."""
    with click.get_text_stream("stdin") as stdin:
        while stdin.readable():
            line = stdin.readline()
            if line:
                yield line.strip().encode("utf-8")