简体   繁体   English

如何在Robot Framework中解析变量

[英]How to parse variables in Robot Framework

I have a variable with value "x: 647, y: 1174" and I would like to parse them into two separate variables: ${x} = 647 and ${y} = 1174 我有一个值为"x: 647, y: 1174"的变量,我想将它们解析为两个独立的变量: ${x} = 647${y} = 1174

Is this possible within Robot Framework? 机器人框架中有可能吗?

String library will help you. 字符串库将帮助您。

${var}    Set Variable    x: 647, y: 1174
${x}    Fetch From Left    ${var}    ,    # now x should be "x: 674"
${x}    Fetch From Right    ${x}    ${SPACE}    # and now it should be "674"
${y}    Fetch From Right    ${var}    y:${SPACE}

Or write a python function that does the same with regex for example. 或者编写一个与正则表达式相同的python函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM