总结:@{}列表类型和${}列表类型都可以表示list类型,均可以通过 set variable 和 create list 创建,区别主要是展示格式和引用格式;
@{}类型可以通过 set variable 和 create list 将其转换成${}类型;
${}类型只能通过 set variable 将其转换成@{};
${}类型通过 create list 将会生成一个只有一个元素的嵌套列表,该唯一的元素值为${}类型本身;
@{list1} set variable 1 2 3
@{list2} create list W E Z
${a} set variable @{list1}
${b} set variable @{list2}
${c} create list @{list1}
${d} create list @{list2}
${list4} set variable 1 2 3
${list3} create list a b c
@{A} set variable ${list4}
@{B} set variable ${list3}
@{C} create list ${list4}
@{D} create list ${list3}
Comment log @{list1[${2}]} #出错
Comment log @{list2[${2}]} #出错
log @{list1}[${2}]
log @{list2}[${2}]
log ${list1[${2}]}
log ${list2[${2}]}
log ----------------------
log ${list4[${2}]}
log ${list3[${2}]}
Comment log @{list4[${2}]} #出错
Comment log @{list3[${2}]} #出错
-------------------------------------------------------------------------运行结果:
20171030 10:09:43.430 : INFO : @{list1} = [ 1 | 2 | 3 ]
20171030 10:09:43.446 : INFO : @{list2} = [ W | E | Z ]
20171030 10:09:43.446 : INFO : ${a} = [u'1', u'2', u'3']
20171030 10:09:43.446 : INFO : ${b} = [u'W', u'E', u'Z']
20171030 10:09:43.446 : INFO : ${c} = [u'1', u'2', u'3']
20171030 10:09:43.446 : INFO : ${d} = [u'W', u'E', u'Z']
20171030 10:09:43.446 : INFO : ${list4} = [u'1', u'2', u'3']
20171030 10:09:43.446 : INFO : ${list3} = [u'a', u'b', u'c']
20171030 10:09:43.446 : INFO : @{A} = [ 1 | 2 | 3 ]
20171030 10:09:43.446 : INFO : @{B} = [ a | b | c ]
20171030 10:09:43.446 : INFO : @{C} = [ [u'1', u'2', u'3'] ]
20171030 10:09:43.446 : INFO : @{D} = [ [u'a', u'b', u'c'] ]
20171030 10:09:43.461 : INFO : 3
20171030 10:09:43.461 : INFO : Z
20171030 10:09:43.461 : INFO : 3
20171030 10:09:43.461 : INFO : Z
20171030 10:09:43.461 : INFO : ----------------------
20171030 10:09:43.461 : INFO : 3
20171030 10:09:43.461 : INFO : c