#!/usr/bin/python3 -u # coding=utf-8 import subprocess, sys pipe = subprocess.Popen(['apt-get', 'download', 'firefox'], 0, stderr = subprocess.STDOUT, stdout = subprocess.PIPE) while True: content = pipe.stdout.read(1).decode() if content == '': break sys.stdout.write(content) pipe.wait()