2009-11-13 11 views
3

Comment passer eof python à stdinpython stdin eof

ici est mon code

p = Popen(commd,stdout=PIPE,stderr=PIPE,stdin=PIPE) 
o = p.communicate(inputstring)[0] 

quand je lance la COMMD dans la ligne de commande après i entrée les fenêtres inputString attendent encore un Ctrl + Z pour terminer accepter l'entrée.

Comment puis-je passer eof ou Ctrl + Z dans le programme?

Merci!

Répondre

9
p.stdin.close() 

après p.communiquer, termine l'entrée et envoie EOF à commd.

+0

merci! après p.communicate (inputString)? – icn

+0

oui. Edité pour clarifier. – fserb