test.py

#coding=utf-8
import subprocess
compilePopen = subprocess.Popen('gcc haha',shell=True,stderr=subprocess.PIPE)
compilePopen.wait()
print('the status code is:',compilePopen.returncode)
with open('log','w') as object:
    object.write(compilePopen.stderr.read())

输出:

('the status code is:', 1)

 

参考:

https://blog.csdn.net/qq_31331027/article/details/80518348

相关文章:

  • 2021-06-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-29
  • 2021-05-03
猜你喜欢
  • 2023-03-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2021-12-21
相关资源
相似解决方案