首页 > 技术文章 > robotfromwork String库

lovecancan 2021-02-20 17:09 原文

1.转换为小写  Convert To Lower Case使用的是python  lower()方法

2.转换标题大小写Convert To Title Case  example[.!?]? 如果第二个单词为大写 第一个单词小写不错大小写转换  例: ${str2}  Convert To Title Case  it's an iphone pro abc  exclude=ab.?  It's An Iphone Pro abc

3.转换位大写Convert To Upper Case使用的是python  lower()方法upper()

4.将字节解码为字符串 Decode Bytes To String/将字符串编码为字节Encode String To Bytes

${string} = Decode Bytes To String ${bytes} UTF-8  
${string} = Decode Bytes To String ${bytes} ASCII errors=ignore

${bytes} = Encode String To Bytes ${string} UTF-8  
${bytes} = Encode String To Bytes ${string} ASCII errors=ignore

5.从左侧获取Fetch From Left返回第一次出现之前的内容如果不到,则返回整个字符串。

6.从右侧获取Fetch From Right返回最后一次出现后的的内容,如果找不到,则返回整个字符串。

7.格式字符串  Format String  ${to} Format StringTo: {} <{}>   cancan    cancan@qq.com   ${to} Format String{:*^30} {:*^30}    cancan    lion    **********dingcancan********** *************lion*************

Format String {0:{width}{base}} ${42} base=X width=10  base=X width=10  指空格

Format String${CURDIR}  positional   获取当前路径

8.产生随机字串  Generate Random String ${to} Generate Random String12   01  12位0  1  之间的数  LOWER小写  UPPER大写  NUMBERS0到9的数字 [NUMBERS]abcdef数字和字母  abcdef纯字母

9.Get Line  Get Line Count

   ${string}   Catenate    111111111111111${\n}1111111111111111111${\n}111111111

   ${first} Get Line Count  ${string}  

   ${first} Get Line  ${string}   -1

10.获取包含字符串的行 Get Lines Containing String

${string} Catenate 111111111111111111${\n}333344445555
${first} Get Lines Containing String ${string} 5  case-insensitive(区分大小写)

11.Get Lines Matching Pattern

${string} Catenate 1${\n}333344445a555
${first} Get Lines Matching Pattern ${string} [1]

12.Get Substring

${string} Catenate 123456321
${first} Get Substring ${string} 2 5

13.Remove String ${str} = Remove String Robot Framework o bt

14.Replace String ${string} Catenate 123123123  ${first} Replace String ${string} 1 b count=2  b23b23123d

15.分割字符串 Split String  ${string} Catenate 123123123  ${first} Split String ${string} 3 1              ['12', '123123']        ${first} Split String To Characters   sasdfasdfsdafdsfdsfsdfdsf

16.Split To Lines  

${string} Catenate 1231${\n}23123
${first} Split To Lines ${string} -1

17.Strip String

 

推荐阅读