From d997910a5dd74c8c40b46b0be3cfce0f82949b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=BC=E5=B0=8F=E8=BE=89=E4=B8=B6?= <760198141@qq.com> Date: Sun, 17 Oct 2021 21:50:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=B0=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Command Line/Problem 4/A.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Command Line/Problem 4/A.py diff --git a/Command Line/Problem 4/A.py b/Command Line/Problem 4/A.py new file mode 100644 index 0000000..0cb699e --- /dev/null +++ b/Command Line/Problem 4/A.py @@ -0,0 +1,10 @@ +import shlex +import subprocess +def run(command): + try: + result = subprocess.getstatusoutput(command, shell=shlex.split(command), stderr=subprocess.STDOUT) + return 0, result + except subprocess.CalledProcessError as e: + return e.returncode, e.output +status, out = run('ls "/"') +print(status, out) \ No newline at end of file -- GitLab