按照您尝试的方式使用check_output,每个命令都必须是您传递的列表中的一个项目。所以,你应该拥有的是:
License = subprocess.check_output(['./generateLicense.sh', '-firstargument', '1', '-secondargument', '2', '-thirdargument', '3'])
这里是您的问题的复制,使用不同的命令来展示当您将多参数命令作为列表中的单个字符串传递给check_output 时发生的情况:
>>> import subprocess
>>> subprocess.check_output(["ls -a"])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 566, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
在 Python 3 中执行此操作实际上会得到更连贯的内容:
FileNotFoundError: [Errno 2] No such file or directory: 'ls -a'