【发布时间】:2016-02-07 15:02:37
【问题描述】:
此代码直接在 CLI 中运行良好:
xmllint --xpath '//Entities[contains(ExpirationDate, '2015')]' app/sftp/file.xml > test.xml
现在,我需要在 Python 环境中执行相同的命令。这就是我正在尝试的:
def process_xml(path):
call(["xmllint --xpath '//Entities[contains(ExpirationDate, '2015')]' app/sftp/file.xml > test.xml"])
这是错误,我正在同一位置运行文件和命令:
OSError: [Errno 2] No such file or directory
【问题讨论】:
-
是
call()函数subprocess.call()吗? -
问题不止于此。它与重定向输出的用法有关,即
>。 -
另外,
def process_xml(path):这个patharg 有什么作用? -
@idjaw 啊,看来你是对的:P
标签: python linux python-2.7 xmllint