Python:将“<”传递给Popen

2024-09-27 09:30:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我想开始比赛测试运行程序.batReadyApi的参数。我尝试将一些XML部分(下面代码中的PeriodEnd)作为参数传递给子流程.Popen地址:

argslist = ['C:/Program Files/SmartBear/ReadyAPI-1.9.0/bin/testrunner.bat',
    '-a', '-s', 'TestSuite', '-c', 'TestCase', '-f', 'C:/temp/', '-P', 
    'PeriodEnd=<PeriodEnd>2017-04-11T00:00:00.000Z</PeriodEnd>', 
    'C:/temp/soapui-project.xml']
proc = Popen(argslist, stdout=PIPE, stderr=PIPE)

这将产生以下错误:

The system cannot find the file specified.

我发现,“<;”和“>;”就是问题所在。我怎样才能逃脱他们或者把他们交给波本?你知道吗


Tags: 代码程序参数地址filesxml流程program
2条回答

\用于转义字符,请尝试\<

https://docs.python.org/2.0/ref/strings.html

可能使用"而不是'

CMD中的转义字符是^。你知道吗

C:\> echo asdf<123>
The syntax of the command is incorrect.

C:\> echo asdf^<123^>
asdf<123>

相关问题 更多 >

    热门问题