How to finish sys.stdin.readlines() input?

For UNIX based systems (Linux, Mac):

Hello, you can type : Ctrld

Ctrld closes the standard input (stdin) by sending EOF.

Example :

>>> import sys
>>> message = sys.stdin.readlines()
Hello
World
My
Name
Is
James
Bond
# <ctrl-d> EOF sent
>>> print message
['Hello\n', 'World\n', 'My\n', 'Name\n', 'Is\n', 'James\n', 'Bond\n']

For Windows :

To send EOF on Windows, type Ctrlz

Leave a Comment

tech