1. List
Create a list in python: a=[1,2,3], b=[], c=[a,b,c,[1,2,3]], d=[a,b,c,1,2 ,3]
Create a list (list) in robotframework: You can see the difference between @ and $ in the list through 3 and 4, $ means to take the first address of the list, @ means to take each element in the list
1、 @{a} create list 1 2 3
2、@{b} create list ${EMPTY}
3、@{c} create list a b c ${a}
4、@{d} create list a b c @{a}
log many @{a},@{b},@{c},@{d}
Example: Create a list [0,1,2,3,4] with a for loop
@{e} create list 0
:FOR ${i} IN RANGE 1 5
\ ${e} create list @{e} ${i}
or
\ ${e} set variable @{e} ${i}
log many @{e}
log many ${e}
In python: Note that it cannot be written as: [1,2,3].append(3)
x=[1,2,3]
x.append(3)
When adding multiple elements to a list at the same time:
rf:${e} create list @{e} ${i} 4 5 6 或者 ${e} set variable @{e} ${i} 4 5 6
python: x.extend([4,5,6])
* take element
rf: Take the third element of the list, pay attention to the difference between @ and $
log many @{e}[2]
log many ${e[2]}
rf: Take the elements at [1], [2], [3] positions
${e} evaluate ${e}[1:4]
*Insert an element, which means insert 1 at position [0]
python: x.insert(0,1)