This might be a silly question, but as I can't find an answer, I have to ask it.
In interactive python I want to process a message which i get with:
>>> message = sys.stdin.readlines()
Everything works fine, but... how to stop it from getting an input and make it save into message variable? Stopping with ctrl+c stops whole process so there is no input to be saved anywhere. I guess there's an easy answer I just can't find...
On windows simply do CTRL+Z and press enter
For unix based system :
Hello, you can tape : Ctrld
Ctrld closes the standard input (stdin) by sending EOF.
Example :
For Windows :
To send EOF on Windows, you can replace Ctrld by Ctrlz
This is an old question but it needs an update about Windows and different keyboard layouts.
If neither CTRL + Z nor CTRL + D ** work for you on Windows and and you're wandering what is going on do this:
This is somewhat strange and counterintuitive. I changed keys layout some time ago to include polish characters, but all the common keys are left unchanged, z still maps to z when I use the keyboard normally, normally ctrl + z does nothing in my keyboard, so I shouldn't be changed. But apparently in cmd it works differently, in order to have default link between ctrl and z I have to switch to default layout, or use control y to sent EOF.
Use
CTRL-D
.