What's the difference between Python's subprocess.call and subprocess.run

前端 未结 2 1960
生来不讨喜
生来不讨喜 2020-12-15 15:05

I\'ve been trying to understand for a while now what\'s the difference between subprocess.call and subprocess.run. I know the last one is new on Py

2条回答
  •  心在旅途
    2020-12-15 15:43

    To make it clear for anyone wanting to know which to use:

    subprocess.run() is the recommended approach for all use cases it can handle. The suprocess documentation states:

    The recommended approach to invoking subprocesses is to use the run() function for all use cases it can handle. For more advanced use cases, the underlying Popen interface can be used directly.

    subprocess.call() is part of the Older high-level API (Prior to Python 3.5).

提交回复
热议问题