我在Python中有以下静态方法。
import subprocess
class ProcessUtility:
@staticmethod
def execute_command(url):
process = None
process = subprocess.check_output(["phantomas " + url + " --har=test.har"])
return process
它基本上将输出写入test.har文件。我已经在与脚本相同的目录中创建了test.har文件,并为其赋予了读取,写入和执行权限。
执行后,我得到了错误。
OSError: [Errno 2] No such file or directory
任何想法,为什么我一直得到这个。
大多数subprocess
函数采用参数列表,而不是字符串(如果shell=False
是)(默认值)。尝试
process = subprocess.check_output(['phantomas', url, '--har=test.har'])
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句