subprocess에서 결과값 받기

2021. 3. 28. 14:04파이썬

결과값과 에러값 받기

    cmd = "text2image --list_available_fonts --fontconfig_tmpdir ./work/tmp --fonts_dir c:/Windows/Fonts"
    print(cmd)
    proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    output = proc.stdout.readlines()
    error = proc.stderr.readlines()
    print(output)
    print(error)

다른 방법

cmd = "text2image --list_available_fonts --fonts_dir %s --fontconfig_tmpdir ./data/tmp" %fonts_dir
out = subprocess.check_output(cmd.split())
print(out)