Last active
December 27, 2015 20:49
-
-
Save xebecnan/7387742 to your computer and use it in GitHub Desktop.
Windows下正确显示程序打印的UTF8中文
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from subprocess import PIPE, Popen, STDOUT | |
args = sys.argv[1:] | |
process = Popen(args, stdout=PIPE, shell=True, stderr=STDOUT) | |
count = 0 | |
while True: | |
buff = process.stdout.readline() | |
if buff == '': | |
count += 1 | |
if buff == '' and process.poll() != None: | |
break | |
sys.stdout.write(buff.decode('utf8')) | |
process.wait() | |
sys.exit(process.returncode) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment