import sys
import os
import subprocess
import inspect
def run_process(cmd_args):
with subprocess.popen(cmd_args) as p:
return (p.communicate())
res = run_process(cmd_args);
if 'with' in inspect.getsource(run_process):
print("'with' used in 'run_process' function definition.\n")
if 'popen' in inspect.getsource(run_process):
print("'popen' used in 'run_process' function definition.\n")
print('process output : %s\n' % (res.decode("utf-8")))
f.close()
我在res.decode
说none type has no attribute decode
时收到错误消息。有人会建议如何处理run_process
函数吗?