[英]Robot Framework how to create dictionary with unknown number of keys?
How to create dictionary when keyword does not know how many args? 当关键字不知道有多少个args时如何创建字典?
I wrote below code, And I want dictionary 我写了下面的代码,我想要字典
${aaaaa} = {'A':'aaa', 'B':'bbb', 'C':'ccc'}
${bbbbb} = {'A':'aaa', 'B':'bbb', 'C':'ccc', 'D': 'ddd'}
Where should I change My Keyword? 我应该在哪里更改我的关键字?
*** Settings ***
Library Collections
*** Test Cases ***
Test AAA
${aaaaa} My Keyword A=aaa B=bbb C=ccc
${bbbbb} My Keyword A=aaa B=bbb C=ccc D=ddd
*** Keywords ***
My Keyword
[Arguments] @{args}
${resp} Create Dictionary ${args}
[Return] ${resp}
If all you're doing to creating a dictionary, just use the create dictionary
keyword. 如果您正在创建字典,请只使用create dictionary
关键字。 However, if you want to create your own keyword which takes a variable number of keyword arguments, use a dictionary as the argument: 但是,如果要创建自己的关键字,该关键字采用可变数量的关键字参数,请使用字典作为参数:
My Keyword
[Arguments] &{args}
[Return] ${args}
This keyword will return a dictionary made up of the keys and values passed in to the keyword 此关键字将返回由传递给关键字的键和值组成的字典
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.