【问题标题】:How to get particular text from a string using robot framework?如何使用机器人框架从字符串中获取特定文本?
【发布时间】:2020-11-30 23:37:32
【问题描述】:

我需要使用robotframework从字符串中获取':'之前的数字我该怎么做?

${str}=    Set Variable  7939:customer-Id:123a34ghas

我只需要在':'之前得到7939,如何在机器人框架中做到这一点?

${Id}=   split string ${str}
log to console   ${Id} #Should give only 7939

【问题讨论】:

    标签: robotframework


    【解决方案1】:
    ${str}=    Set Variable    7939:customer-Id:123a34ghas
    
    ${Id}=    split string    ${str}    :
    
    log to console    ${Id}[0]    #prints 7939
    

    【讨论】:

    • 请始终格式化代码,尤其是在这里使用 RF,我只是复制您的示例/解决方案,它不会起作用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-16
    • 1970-01-01
    • 2023-02-03
    • 2020-12-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多