我可以在 Robot Framework 的字典中声明一个列表吗
Can I declare a list inside a dictionary in Robot Framework
我是机器人框架的新手
任何人都可以帮助解决这个问题。
在python中我们可以声明一个包含列表的字典
dict = {"key1":[1,2,3,4,5], "key2":3, "key3":"string"}
我想知道我们是否可以在机器人框架中做同样的事情?
您可以通过 Create List and Create Dictionary 关键字来完成:
*** Test Cases ***
Example 1
${key1} Create list # coerce values to integers
${key2} Set variable # coerce to integer
${key3} Set variable string
${dict}= Create dictionary
... key1=${key1}
... key2=${key2}
... key3=${key3}
从机器人框架 3.2 开始,您可以通过在 ${{
和 }}
之间放置一个 python 表达式来使用 inline evaluation。例如:
*** Test Cases ***
Example 2
${dict}= Set variable ${{ {"key1":[1,2,3,4,5], "key2":3, "key3":"string"} }}
内联计算的好处是您可以在变量部分使用它:
*** Variables ***
${dict} ${{ {"key1":[1,2,3,4,5], "key2":3, "key3":"string"} }}
我是机器人框架的新手
任何人都可以帮助解决这个问题。
在python中我们可以声明一个包含列表的字典
dict = {"key1":[1,2,3,4,5], "key2":3, "key3":"string"}
我想知道我们是否可以在机器人框架中做同样的事情?
您可以通过 Create List and Create Dictionary 关键字来完成:
*** Test Cases ***
Example 1
${key1} Create list # coerce values to integers
${key2} Set variable # coerce to integer
${key3} Set variable string
${dict}= Create dictionary
... key1=${key1}
... key2=${key2}
... key3=${key3}
从机器人框架 3.2 开始,您可以通过在 ${{
和 }}
之间放置一个 python 表达式来使用 inline evaluation。例如:
*** Test Cases ***
Example 2
${dict}= Set variable ${{ {"key1":[1,2,3,4,5], "key2":3, "key3":"string"} }}
内联计算的好处是您可以在变量部分使用它:
*** Variables ***
${dict} ${{ {"key1":[1,2,3,4,5], "key2":3, "key3":"string"} }}