subprocess.Popen的stdout输出打印
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import subprocess command = "df -Th" result = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) for line in result.stdout: line = line.decode("utf-8", "ignore") print(line)