问题
In Robot Framework, we can assign a list to a Scalar Variable or to a List Variable, as shown below:
| @{list} = | Create List | a | b | c |
| ${scalar} = | Create List | a | b | c |
What is the difference between a List Variable and a Scalar Variable containing a list?
回答1:
In case of the assignment shown in your question, there is no difference. If you log each of those you'll get the exact same output.
Note: this functionality was introduced in version 2.8 (see Using scalar variables as lists in Robot Framework User's Guide).
The difference comes when you use the values. When you use the @
symbol to reference a list, each of the elements in the list becomes a cell. In the following example, the following three lines give identical results:
| | A keyword that expects three arguments | a | b | c
| | A keyword that expects three arguments | @{list}
| | A keyword that expects three arguments | @{scalar}
来源:https://stackoverflow.com/questions/25602405/in-robot-framework-what-is-the-difference-between-a-list-variable-and-a-scalar