Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在robot框架中计算引号中的表达式失败_Python_Robotframework - Fatal编程技术网

Python 在robot框架中计算引号中的表达式失败

Python 在robot框架中计算引号中的表达式失败,python,robotframework,Python,Robotframework,上面的代码给出错误,因为计算表达式失败:语法错误:无效语法(,第1行) 单引号导致了这个问题,但我不想更改变量值并按原样对其进行评估。用双引号替换也不起作用,并给出相同的错误 有人能建议如何计算吗?为了正确地转义字符串,需要使用三重引号。这段代码运行良好 *** Variables *** ${text1} Jack's mother said "Hello" to me ${text2} Jack's mother said "Hello&

上面的代码给出错误,因为计算表达式失败:语法错误:无效语法(,第1行)

单引号导致了这个问题,但我不想更改变量值并按原样对其进行评估。用双引号替换也不起作用,并给出相同的错误


有人能建议如何计算吗?

为了正确地转义字符串,需要使用三重引号。这段代码运行良好

*** Variables ***

${text1}      Jack's mother said "Hello" to me 
${text2}      Jack's mother said "Hello" to me

*** Test Cases ***
    ${result}=    Set Variable If    '${text1}' in '${text2}'    ${TRUE}    ${FALSE}

有关详细信息,请查看

您可以通过删除变量名称中的大括号,直接在表达式中使用robot变量

   *** Variables ***
    ${text1}      Jack's mother said "Hello" to me
    ${text2}      Jack's mother said "Hello" to me
    
    *** Test Cases ***
    Test
        ${result}=    Set Variable If    '''${text1}''' in '''${text2}'''    ${TRUE}    ${FALSE}

这在内置库文档中的“不使用”一节中有所介绍,该节也给出了相同的说明error@Hunter:这是个坏建议,不能解决问题。
${result}=    Set Variable If    $text1 in $text2    ${TRUE}    ${FALSE}