Home > other >  For help: the Python Subprocess. The popen () returns the object's stdin why write how to use t
For help: the Python Subprocess. The popen () returns the object's stdin why write how to use t

Time:10-21

As title, can you tell me the masters... you
 
Class Thread (threading. Thread) :
Def __init__ (self, name, sub) :
Threading. Thread. __init__ (self)
The self. The name=name
The self. The sub=sub

Def run (self) :
While True:
If the self. The sub. The poll () is not None:
Break
The command=bytes (STR (input (" the console: "). The encode (' utf-8)), encoding="utf-8")
# print (type (command))
The self. The sub. Stdin. Write (command)
Is_input_started=False
While True:
The empty=False
Try:
Enter=STR (input (' main file path: '))
Except SyntaxError:
The empty=True
If not the empty:
If the STR (input (' sure path? (y, n) : '))=='y' :
Break
Sub=subprocess. Popen (enter, shell=True, stdout=subprocess. The PIPE, stdin=subprocess. The PIPE, stderr=subprocess. The PIPE)
While True:
If sub. Poll () is not None:
Print (' Stopped ')
Break
Out=sub. Stdout. Readline ()
If not out=="" :
Print (out)
If not is_input_started:
Thread=thread. The thread (' input, sub)
Thread. The start ()
Is_input_started=True

There is no any response after input, how to do
  • Related