在Robot Framework中,列表变量和包含列表的标量变量之间有什么区别?

use*_*pal 6 variables scalar list robotframework

在Robot Framework中,我们可以将列表分配给标量变量或列表变量,如下所示:

| @{list} =   | Create List | a | b | c |
| ${scalar} = | Create List | a | b | c |
Run Code Online (Sandbox Code Playgroud)

列表变量和包含列表的标量变量之间有什么区别?

Bry*_*ley 8

如果您的问题中显示了作业,则没有区别.如果您记录每一个,您将获得完全相同的输出.

注意:此功能是在2.8版中引入的(请参阅在Robot Framework用户指南中使用标量变量作为列表).

使用这些值时会出现差异.使用@符号引用列表时,列表中的每个元素都将成为一个单元格.在以下示例中,以下三行给出相同的结果:

| | A keyword that expects three arguments | a | b | c
| | A keyword that expects three arguments | @{list}
| | A keyword that expects three arguments | @{scalar}
Run Code Online (Sandbox Code Playgroud)