如何将长字符串一分为二

时间:2018-06-27 10:34:55

标签: split robotframework

示例:

Log To Console   This is a very very very very very very very very very very very very very very very very very very very very very very long string

上面的字符串很长,因此不适合1行,因此我想将其拆分为2个(或更多)部分,并将每个部分放在单独的行中。像这样(在C ++中):

cout << "This is a very very very very very very very very very very very very"
        " very very very very very very very very very very long string" << endl;

2 个答案:

答案 0 :(得分:4)

使用Catenate关键字和省略号(...)进行行继续:

${long var}=    Catenate     This is a very very very very very very very very very very very very
                   ...       very very very very very very very very very very long string
Log To Console  My long variable is: ${long var}

默认情况下,它为参数填充空格,可以使用SEPARATOR参数更改(必须是第一个传递给关键字的参数)。

答案 1 :(得分:3)

使用评估可能也可以:

${varA} =    Set Variable    Head of the string -
${varB} =    Set Variable    which is just too long
${result} =     Evaluate    ${varA}${varB}