1

I've started playing around with writing a GUI for a bitcoin miner and right now I just have a window with a "Start" and "Stop" button and I've got those working so you click start and it uses self.p = subprocess.Popen(args) to open the process and self.p.terminate() to end the process. My next step is to read the speed of the miner from it's output. How do I read the output from the process?

4

2 回答 2

2

Use Popen.communicate to read the output. For example.

import subprocess

p = subprocess.Popen('ls', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# returns a tuple containing the the stdout and stderr of the program
res, err = p.communicate() 
于 2011-06-24T21:21:47.320 回答
1

you call:

out, err = p.communicate()
于 2011-06-24T21:13:44.960 回答