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)

 

 

posted @ 2022-10-10 12:01  捧花大王  阅读(260)  评论(0编辑  收藏  举报